<?php
require_once (dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Config' . DIRECTORY_SEPARATOR . 'Common.php');
require_once (dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Config' . DIRECTORY_SEPARATOR . 'Search.php');
require_once (dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Config' . DIRECTORY_SEPARATOR . 'Shop.php');
require_once (dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Config' . DIRECTORY_SEPARATOR . 'Sp.php');
require_once (dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Bukkenurl.php');

/**
 * 疑似静的URL対応
 *
 * @param string $url
 *            静的URL
 * @return void
 */
function __set_url($url, $method)
{
    if (ereg('/asn/1/contents/(.*)', $url))
    {
        $url = ereg_replace('/asn/1/contents/', '/', $url);
    }

    $front = Zend_Controller_Front::getInstance();

    $router = $front->getRouter();

    $isMobile = false;

    if (ereg('^/sp/', $url))
    {
        $isMobile = true;
    }

    if (true)
    {
        if ($isMobile)
        {
            $p = __get_parameters_by_url_for_sp($url, $method);
        }
        else
        {
            $p = __get_parameters_by_url($url, $method);
        }

        $pat = $p['Pattern'];

        // PC用のルーター
        if (substr($pat, 0, 6) == 'renew_')
        {
            $controller = substr($pat, 6);

            if ($method == 'GET')
            {
                $action = 'index';
                $http_params = $_GET;
            }
            else if ($method == 'POST')
            {

                // AJAXカールじゃない
                if (!isset($p['AMethod']) || $p['AMethod'] == '')
                {
                    $action = 'post';
                }
                // AJAXカール
                else
                {
                    $action = $p['AMethod'];
                }
                $http_params = $_POST;
            }

            // add 20141231
            if ($pat == "renew_requestsearh_regist")
            {
                $route = new Zend_Controller_Router_Route('*', array(
                    'module' => 'inquiry',
                    'controller' => 'apirequest',
                    'action' => $action,
                    'parameters' => $p
                ));
                $router->addRoute('inquiry', $route);
                return;
            }

            $params = array(
                'module' => 'renew',
                'controller' => $controller,
                'action' => $action,
                'parameters' => $p,
                'http_params' => $http_params
            );

            $route = new Zend_Controller_Router_Route('*', $params);
            $router->addRoute('renew_' . $controller . 'page', $route);
            return;
        }
        // スマホ用のルーター
        else if (substr($pat, 0, 10) == 'mobileapi_')
        {
            $controller = substr($pat, 10);

            if ($method == 'GET')
            {
                $action = 'index';
                $http_params = $_GET;
            }
            else if ($method == 'POST')
            {
                $action = 'post';
                $http_params = $_POST;
            }

            // add 20141231
            if ($pat == "mobileapi_requestsearch_regist")
            {
                // 20150126 S_Add
                if (!isset($p['isMobile']))
                {
                    $p['isMobile'] = 1;
                    $p['vintGenruFlg'] = 95;
                }
                // 20150126 E_Add
                $route = new Zend_Controller_Router_Route('*', array(
                    'module' => 'inquiry',
                    'controller' => 'apirequest',
                    'action' => $action,
                    'parameters' => $p
                ));
                $router->addRoute('inquiry', $route);
                return;
            }

            $params = array(
                'module' => 'mobileapi',
                'controller' => $controller,
                'action' => $action,
                'parameters' => $p,
                'http_params' => $http_params
            );

            $route = new Zend_Controller_Router_Route('*', $params);
            $router->addRoute('mobileapi_' . $controller . 'page', $route);
            return;
        }
        error_log('unknown module [' . $p['Category'] . ']');
        if ($pat == 'x4' && $p['Category'] == 3)
        {
            $controller = 'list';
            if ($isMobile)
            {
                $params = array(
                    'module' => 'mobileapi',
                    'controller' => $controller,
                    'action' => 'x',
                    'parameters' => $p,
                    'http_params' => $http_params
                );
                $route = new Zend_Controller_Router_Route('*', $params);
                $router->addRoute('mobileapi_' . $controller . 'page', $route);
            }
            else
            {
                $params = array(
                    'module' => 'renew',
                    'controller' => $controller,
                    'action' => 'x',
                    'parameters' => $p,
                    'http_params' => $http_params
                );
                $route = new Zend_Controller_Router_Route('*', $params);
                $router->addRoute('renew_' . $controller . 'page', $route);
            }
            error_log($controller);
            return;
        }
    }
    switch ($pat)
    {

        // 店舗検索
        case 'shop':

            if ($p['Category'] == '0')
            {
                $route = new Zend_Controller_Router_Route('*', array(
                    'module' => 'shop',
                    'controller' => 'index',
                    'action' => 'index',
                    'parameters' => $p
                ));
                $router->addRoute('shop', $route);
            }
            elseif ($p['Category'] == '2')
            {
                $route = new Zend_Controller_Router_Route('*', array(
                    'module' => 'shop',
                    'controller' => 'selcity',
                    'action' => 'index',
                    'parameters' => $p
                ));
                $router->addRoute('shop', $route);
            }
            elseif ($p['Category'] == '3')
            {
                $route = new Zend_Controller_Router_Route('*', array(
                    'module' => 'shop',
                    'controller' => 'rstshoplist',
                    'action' => 'index',
                    'parameters' => $p
                ));
                $router->addRoute('shop', $route);
            }

            break;

        // 店舗詳細
        case 'shop_detail':

            if ($p['Category'] == '9')
            {

                // 加盟店サイト
                $route = new Zend_Controller_Router_Route('*', array(
                    'module' => 'shop',
                    'controller' => 'shoppage',
                    'action' => 'index',
                    'parameters' => $p
                ));
                $router->addRoute('shoppage', $route);
            }
            else
            {
                // 店舗詳細
                $route = new Zend_Controller_Router_Route('*', array(
                    'module' => 'shop',
                    'controller' => 'shopdtl',
                    'action' => 'index',
                    'parameters' => $p
                ));
                $router->addRoute('shopdtl', $route);
            }

            break;

        // 住居形態
        case 'type':

            $route = new Zend_Controller_Router_Route('*', array(
                'module' => 'search',
                'controller' => 'jyukyokeitaisearch',
                'action' => 'index',
                'parameters' => $p
            ));

            $router->addRoute('jyukyokeitai', $route);
            break;

        // エリア
        case 'chiiki':

            if ($p['Category'] == '1')
            {

                $route = new Zend_Controller_Router_Route('*', array(
                    'module' => 'search',
                    'controller' => 'areasearch',
                    'action' => 'index',
                    'parameters' => $p
                ));
                $router->addRoute('area', $route);
            }
            elseif ($p['Category'] == '1.5')
            {

                $route = new Zend_Controller_Router_Route('*', array(
                    'module' => 'search',
                    'controller' => 'areasearch',
                    'action' => 'pref',
                    'parameters' => $p
                ));
                $router->addRoute('area', $route);
            }
            elseif ($p['Category'] == '2')
            {

                $route = new Zend_Controller_Router_Route('*', array(
                    'module' => 'search',
                    'controller' => 'jyusyosearch',
                    'action' => 'index',
                    'parameters' => $p
                ));
                $router->addRoute('jyusyo', $route);
            } /*
               * elseif($p['Category'] == '2_1'){ $route = new Zend_Controller_Router_Route( '*',
               * array( 'module' => 'search', 'controller' => 'jyusyosearch', 'action' => 'index',
               * 'parameters' => $p ) ); $router->addRoute('jyusyo', $route); }
               */
            elseif ($p['Category'] == '2.5')
            {

                $route = new Zend_Controller_Router_Route('*', array(
                    'module' => 'search',
                    'controller' => 'jyusyosearch',
                    'action' => 'index',
                    'parameters' => $p
                ));
                $router->addRoute('jyusyo', $route);
            }
            elseif ($p['Category'] == '3.5')
            {

                $route = new Zend_Controller_Router_Route('*', array(
                    'module' => 'search',
                    'controller' => 'jyusyosearch',
                    'action' => 'index',
                    'parameters' => $p
                ));
                $router->addRoute('jyusyo', $route);
            }

            else
            {

                $route = new Zend_Controller_Router_Route('*', array(
                    'module' => 'rstobi',
                    'controller' => 'rstobi',
                    'action' => 'index',
                    'parameters' => $p
                ));
                $router->addRoute('rstobi', $route);
            }

            break;

        // 駅・路線
        case 'station':

            if ($p['Category'] == '3' || $p['Category'] == '2.5l')
            {

                $route = new Zend_Controller_Router_Route('*', array(
                    'module' => 'rstobi',
                    'controller' => 'rstobi',
                    'action' => 'index',
                    'parameters' => $p
                ));

                $router->addRoute('rstobi', $route);
            }
            else
            {

                $route = new Zend_Controller_Router_Route('*', array(
                    'module' => 'search',
                    'controller' => 'ensenekisearch',
                    'action' => 'index',
                    'parameters' => $p
                ));
                $router->addRoute('enseneki', $route);
            }

            break;

        // こだわり
        case 'kodawari':

            if ($p['Category'] == '0')
            {
                $route = new Zend_Controller_Router_Route('*', array(
                    'module' => 'search',
                    'controller' => 'kodawari',
                    'action' => 'index',
                    'parameters' => $p
                ));
                $router->addRoute('kodawari', $route);
            }
            else
            {
                $route = new Zend_Controller_Router_Route('*', array(
                    'module' => 'search',
                    'controller' => 'kodawarisearch',
                    'action' => 'index',
                    'parameters' => $p
                ));
                $router->addRoute('kodawari', $route);
            }

            break;

        case 'x2':

            if ($p['Category'] == '1')
            {

                $route = new Zend_Controller_Router_Route('*', array(
                    'module' => 'search',
                    'controller' => 'areasearch',
                    'action' => 'index',
                    'parameters' => $p
                ));
                $router->addRoute('area', $route);
            }
            elseif ($p['Category'] == '2' || $p['Category'] == '2.5')
            {

                $route = new Zend_Controller_Router_Route('*', array(
                    'module' => 'search',
                    'controller' => 'jyukyokeitaisearch',
                    'action' => 'index',
                    'parameters' => $p
                ));
                $router->addRoute('jyukyokeitai', $route);
            }
            elseif ($p['Category'] == '3.5')
            {

                $route = new Zend_Controller_Router_Route('*', array(
                    'module' => 'search',
                    'controller' => 'jyusyosearch',
                    'action' => 'index',
                    'parameters' => $p
                ));
                $router->addRoute('jyusyo', $route);
            }
            else
            {
                $route = new Zend_Controller_Router_Route('*', array(
                    'module' => 'rstobi',
                    'controller' => 'rstobi',
                    'action' => 'index',
                    'parameters' => $p
                ));
                $router->addRoute('rstobi', $route);
            }

            break;

        case 'x2s':

            $route = new Zend_Controller_Router_Route('*', array(
                'module' => 'rstobi',
                'controller' => 'rstobi',
                'action' => 'index',
                'parameters' => $p
            ));
            $router->addRoute('rstobi', $route);

            break;

        case 'x3':
            $route = new Zend_Controller_Router_Route('*', array(
                'module' => 'search',
                'controller' => 'kodawarisearch',
                'action' => 'index',
                'parameters' => $p
            ));
            $router->addRoute('kodawari', $route);
            break;

        case 'x4':
            if ($p['Category'] == '1')
            {

                $route = new Zend_Controller_Router_Route('*', array(
                    'module' => 'search',
                    'controller' => 'areasearch',
                    'action' => 'index',
                    'parameters' => $p
                ));
                $router->addRoute('area', $route);
            }
            elseif ($p['Category'] == '2' || $p['Category'] == '2.5')
            {

                $route = new Zend_Controller_Router_Route('*', array(
                    'module' => 'search',
                    'controller' => 'kodawarisearch',
                    'action' => 'index',
                    'parameters' => $p
                ));
                $router->addRoute('kodawari', $route);
            }
            elseif ($p['Category'] == '3.5')
            {

                $route = new Zend_Controller_Router_Route('*', array(
                    'module' => 'search',
                    'controller' => 'jyusyosearch',
                    'action' => 'index',
                    'parameters' => $p
                ));
                $router->addRoute('jyusyo', $route);
            }
            else
            {

                $route = new Zend_Controller_Router_Route('*', array(
                    'module' => 'rstobi',
                    'controller' => 'rstobi',
                    'action' => 'index',
                    'parameters' => $p
                ));
                $router->addRoute('rstobi', $route);
            }
            break;

        case 'x4s':

            $route = new Zend_Controller_Router_Route('*', array(
                'module' => 'rstobi',
                'controller' => 'rstobi',
                'action' => 'index',
                'parameters' => $p
            ));
            $router->addRoute('rstobi', $route);

            break;

        case 'x5':

            if ($p['Category'] == '1')
            {

                $route = new Zend_Controller_Router_Route('*', array(
                    'module' => 'search',
                    'controller' => 'areasearch',
                    'action' => 'index',
                    'parameters' => $p
                ));
                $router->addRoute('area', $route);
            }
            elseif ($p['Category'] == '2' || $p['Category'] == '2.5' || $p['Category'] == '3.5')
            {

                $route = new Zend_Controller_Router_Route('*', array(
                    'module' => 'search',
                    'controller' => 'jyusyosearch',
                    'action' => 'index',
                    'parameters' => $p
                ));
                $router->addRoute('jyusyo', $route);
            }
            else
            {

                $route = new Zend_Controller_Router_Route('*', array(
                    'module' => 'rstobi',
                    'controller' => 'rstobi',
                    'action' => 'index',
                    'parameters' => $p
                ));
                $router->addRoute('rstobi', $route);
            }

            break;

        case 'x5s':
            $route = new Zend_Controller_Router_Route('*', array(
                'module' => 'rstobi',
                'controller' => 'rstobi',
                'action' => 'index',
                'parameters' => $p
            ));
            $router->addRoute('rstobi', $route);
            break;

        case 'detail':
            $route = new Zend_Controller_Router_Route('*', array(
                'module' => 'rstdtl',
                'controller' => 'bukendtl',
                'action' => 'index',
                'parameters' => $p
            ));
            $router->addRoute('rstdtl', $route);
            break;

        case 'inquiry_b':
            $route = new Zend_Controller_Router_Route('*', array(
                'module' => 'inquiry',
                'controller' => 'bukkenentry',
                'action' => 'index',
                'parameters' => $p
            ));
            $router->addRoute('inquiry', $route);
            break;

        case 'inquiry_a':
            $route = new Zend_Controller_Router_Route('*', array(
                'module' => 'inquiry',
                'controller' => 'asmemberentry',
                'action' => 'index',
                'parameters' => $p
            ));
            $router->addRoute('inquiry', $route);
            break;
        default:

            // TODO : デフォルトの場合の遷移先が不明
            break;
    }
}

/**
 * 静的URL振り分け
 *
 * @access public
 * @param string $url
 *            静的URL
 * @return void
 */
function __get_parameters_by_url($url, $method)
{
    $params = array();
    $value = array();
    $value2 = array();

    $kodawariFlag = false;
    $typeFlag = false;
    $areaFlag = false;
    $prefFlag = false;
    $stationFlag = false;
    $chikiFlag = false;
    $shopFlag = false;

    // パラメータをセット
    $ar_params = '';
    $ar_url = explode('?', $url);
    $ar_params = explode('&', $ar_url[1]);
    if (is_array($ar_params))
    {
        foreach ($ar_params as $key => $val)
        {
            if (!empty($val))
            {
                $ar_val = explode('=', $val);
                // $params[$ar_val[0]] = urldecode($ar_val[1]);
                $params[$ar_val[0]] = $ar_val[1];
            }
        }
    }
    $request_params = array_merge($_POST, $_GET);
    $request_SrhKbn = $request_params['SrhKbn'];

    // ------------------------------------------------------------------------

    if ($url == '/' || ereg("^/top/", $url) || ereg("^/index(.*)", $url) || ereg("^/\?(.*)", $url))
    {
        $value = split('/', $url);
        $params['Pattern'] = 'renew_top';
        $params['Category'] = $value[2];
        return $params;
    }

    $value = split('/', $ar_url[0]);
    $vlen = count($value);

    /*
     * if ($vlen >= 5) { if ($value[1] == "r_apart") { $vlen --; array_shift($value);
     * $params['syubetu1'] = 'on'; } else if ($value[1] == "r_mansion") { $vlen --;
     * array_shift($value); $params['syubetu2'] = 'on'; } else if ($value[1] == "r_kodate") { $vlen
     * --; array_shift($value); $params['syubetu3'] = 'on'; } }
     */

    $a = array_shift($value);
    $b = array_shift($value);
    $c = array_shift($value);

    // 家賃相場
    if ($b == 'yachinsobasearch')
    {
        $d1 = array_shift($value);
        $d2 = array_shift($value);
        // tho add
        /*
         * echo ' a:'.$a; echo ' b:'.$b; echo ' c:'.$c; echo ' d1:'.$d1; echo ' d2:'.$d2;
         */
        // 家賃相場条件選択
        if (empty($c))
        {
            $params['Pattern'] = 'renew_yachinsobasearch';
            return $params;
        }
        // 家賃相場全国地図
        if (!empty($c))
        {
            // 物件種別＋間取
            $params['YachinSobaType'] = $c; // 4桁

            if (empty($d1))
            {
                $params['Pattern'] = 'renew_yachinsobasearchmap';
                return $params;
            }

            $params['Area'] = $d1; // 地域

            if ($d2 == 'line')
            {
                $d3 = array_shift($value);

                // 路線選択
                if (empty($d3))
                {
                    $params['Pattern'] = 'renew_yachinsobasearchroute';
                    return $params;
                }
                // 路線の家賃相場
                else
                {
                    $params['RailCd'] = array();
                    $params['RailCd'][] = $d3;
                    $params['Pattern'] = 'renew_yachinsobasearchresult';
                    return $params;
                }
            }
            // 都道府県の家賃相場
            else
            {
                $params['Pattern'] = 'renew_yachinsobasearchresult';
                return $params;
            }
        }
    }

    // 空白文字を除いてURLパーツを保存する。ルーティングのために使う。
    $urlparts = preg_split('@/@', $ar_url[0], NULL, PREG_SPLIT_NO_EMPTY);
    $params['UrlParts'] = $urlparts;

    if ($vlen == 3 || ($b == in_array($b, Apm_Config_Search::$TODOUFUKEN_NAME_CODE_LIST) && ($c == "apart" || $c == "mansion" || $c == "kodate" || $c == "kodawari")))
    {

        // ※TODOUFUKEN_NAMEを先にチェックすることに注意.
        // AREA_NAMEを先にチェックすると /hokkaido/ をtopにルーティングしてしまう.
        if (in_array($b, Apm_Config_Search::$TODOUFUKEN_NAME_CODE_LIST))
        {

            $params['Pattern'] = 'renew_area';
            $params['Area'] = $b;
            return $params;
        }
        if (in_array($b, Apm_Config_Search::$AREA_NAME_CODE_LIST))
        {
            $params['Pattern'] = 'renew_top';
            $params['Category'] = $b;
            return $params;
        }
        if ($b == 'shop' && ereg('^rstshoplist', $c) && array_key_exists("SrhType", $request_params))
        {
            $params['Pattern'] = 'renew_shoplist';
            $typ = $params['SrhType'];
            if ($typ == 1)
                $params['Category'] = 'area2';
            else if ($typ == 2)
                $params['Category'] = 'line';
            else if ($typ == 3) $params['Category'] = 'free';
            return $params;
        }

        if ($method == 'POST' && $b == 'rstobi' && $c == 'rstobi' && !array_key_exists('OemCd', $request_params) && !array_key_exists('ComId', $request_params) && $request_SrhKbn != Apm_Config_Search::SRHKBN_ROSENZU && $request_SrhKbn != Apm_Config_Search::SRHKBN_TUKINTUGAKU && $request_SrhKbn != Apm_Config_Search::SRHKBN_SUMITAIEKI && $request_SrhKbn != Apm_Config_Search::SRHKBN_FREEWORD && $request_SrhKbn != Apm_Config_Search::SRHKBN_YACHINSOUBA && $request_SrhKbn != Apm_Config_Search::SRHKBN_CHINRYOMADORI && $request_SrhKbn != Apm_Config_Search::SRHKBN_GAKKONAME)
        {
            $params['Pattern'] = 'renew_list';
            return $params;
        }

        // ★★★複数地域か駅を選択すると→希望条件ページ転移
        if ($method == 'POST' && $c == 'hope')
        {
            $params['Pattern'] = 'renew_hope';
            return $params;
        }
        // ★★★複数地域か駅を選択すると→希望条件ページ転移

        // ★★★物件一覧から→町探しページ転移
        if ($method == 'POST' && $c == 'town')
        {
            $params['Pattern'] = 'renew_town';
            return $params;
        }
        // ★★★物件一覧から→町探しページ転移

        // Ajax呼ぶ
        if ($b == 'areaajax')
        {
            $params['Pattern'] = 'renew_areaajax';
            $params['AMethod'] = $c; // メソッド名
            return $params;
        }
        // Ajax呼ぶ

        // 20141214 S_Add
        // Ajax呼ぶ　店舗検索
        if ($b == 'shopajax')
        {
            $params['Pattern'] = 'renew_shopajax';
            $params['AMethod'] = $c; // メソッド名
            return $params;
        }
        // 20141214 E_Add

        // 20141220 S_Add
        // Ajax呼ぶ　条件問い合わせ検索
        if ($b == 'conditionsajax')
        {
            $params['Pattern'] = 'renew_conditionsajax';
            $params['AMethod'] = $c; // メソッド名
            return $params;
        }
        // 20141220 E_Add

        // トップモーダル
        if ($b == 'topmodal' && $c == 'modal')
        {
            $params['Pattern'] = 'renew_modal';
            return $params;
        }
        // トップモーダル

        // ★★★検討リスト
        if ($b == 'user')
        {
            if ($c == 'study')
            {
                $params['Pattern'] = 'renew_study';
            }
            else if ($c == 'recent')
            {
                $params['Pattern'] = 'renew_recent';
            }
            else if ($c == 'favoritelist')
            {
                $params['Pattern'] = 'renew_favoritelist';
            }
            return $params;
        }
        // ★★★検討リスト

        // 通勤通学検索 add jschoi 20141217
        if ($b == 'search')
        {
            // 簡単検索じゃない
            if ($c == 'tsukintsugakujikansearch')
            {
                $params['Pattern'] = 'renew_search';
                $params['Method'] = $c;
                return $params;
            }
            else if ($c == 'requestsearch')
            {
                // 2015/01/30 簡単リクエストへ戻すための作業 start
                // $params['Pattern'] = 'renew_requestsearch';
                // $params['Method'] = $d;

                // if($d == "regist")
                // $params['Pattern'] = "renew_requestsearh_regist";
                // 2015/01/30 簡単リクエストへ戻すための作業 end

                return $params;
            }
        }
        // 通勤通学検索

        // ショップ詳細
        if ($b == 'shop')
        {
            if (ereg('^[0-9]+$', $c))
            {
                $params['Pattern'] = 'renew_shopdetail';
                $params['Code'] = $c;
                return $params;
            }
        }

        // ★★★タイプ、こだわり
        if ($b == "apart" || $b == "mansion" || $b == "kodate" || $b == "kodawari")
        {
            if ($b == "apart")
            {
                $params['syubetu1'] = 'on';
            }
            else if ($value[1] == "mansion")
            {
                $params['syubetu2'] = 'on';
            }
            else if ($value[1] == "kodate")
            {
                $params['syubetu3'] = 'on';
            }

            $params['conditions'] = preg_split('@/@', $ar_url[0], NULL, PREG_SPLIT_NO_EMPTY);

            $params['Pattern'] = 'renew_othersearch';
            return $params;
        }
        // ★★★タイプ、こだわり
    }
    else if ($vlen >= 4)
    {

        $d = array_shift($value);
        $e = array_shift($value);
        $f = array_shift($value);
        $g = array_shift($value);
        $h = array_shift($value);

        // 物件詳細
        if ($b == 'detail')
        {
            $params['Pattern'] = 'renew_detail';
            $params['Type'] = 'detail2';
            $params['Code'] = $c;
            return $params;
        }

        // 建物詳細
        if ($b == 'article')
        {

            // 最初文字が【b】
            if (substr($c, 0, 1) == 'b')
            {
                $code = substr($c, 1);
                // 物件詳細
                if (isset($d) && !empty($d))
                {
                    $params['Pattern'] = 'renew_detail';
                    $params['Type'] = 'detail2';
                    $params['Code'] = $d;
                    return $params;
                }
                // 建物詳細
                else
                {
                    $params['Pattern'] = 'renew_article';
                    $params['Type'] = 'detail2';
                    $params['Code'] = $code;
                    return $params;
                }
            }
            // 最初文字が【b】じゃない→建物詳細
            else
            {
                $params['Pattern'] = 'renew_article';
                $params['Type'] = 'detail2';
                $params['Code'] = $c;
            }
            return $params;
        }

        // ★★★建物詳細静的ページ
        // http://xxx.com/todoufuken/bxxx/
        if ($b != 'inquiry' && substr($c, 0, 1) == 'b' && !strpos($c, 'entry') && $c !== 'bukendtl')
        {
            $code = substr($c, 1);
            if (ereg("^[0-9]+$", $code))
            {

                // 物件詳細
                if (isset($d) && !empty($d))
                {
                    $params['Pattern'] = 'renew_detail';
                    $params['Type'] = 'detail2';
                    $params['Code'] = $d;
                    return $params;
                }
                // 建物詳細
                else
                {
                    $params['Pattern'] = 'renew_article';
                    $params['Type'] = 'detail2';
                    $params['Code'] = $code;
                    return $params;
                }
            }
            else
            {
                $params['Pattern'] = 'renew_article';
                $params['Type'] = 'detail2';
                $params['Code'] = $c;
                return $params;
            }
        }
        // http://xxx.com/todoufuken/shiku/bxxx/
        if ($b != 'inquiry' && substr($d, 0, 1) == 'b' && !strpos($d, 'entry'))
        {
            $code = substr($d, 1);
            if (ereg("^[0-9]+$", $code))
            {
                // 物件詳細
                if (isset($e) && !empty($e))
                {
                    $params['Pattern'] = 'renew_detail';
                    $params['Type'] = 'detail2';
                    $params['Code'] = $e;
                    return $params;
                }
                // 建物詳細
                else
                {
                    $params['Pattern'] = 'renew_article';
                    $params['Type'] = 'detail2';
                    $params['Code'] = $code;
                    return $params;
                }
            }
            else
            {
                $params['Pattern'] = 'renew_article';
                $params['Type'] = 'detail2';
                $params['Code'] = $d;
                return $params;
            }
        }
        // http://xxx.com/todoufuken/shiku/apart/bxxx
        if ($b != 'inquiry' && substr($e, 0, 1) == 'b')
        {
            $code = substr($e, 1);
            if (ereg("^[0-9]+$", $code))
            {

                // 物件詳細
                if (isset($f) && !empty($f))
                {
                    $params['Pattern'] = 'renew_detail';
                    $params['Type'] = 'detail2';
                    $params['Code'] = $f;
                    return $params;
                }
                // 建物詳細
                else
                {
                    $params['Pattern'] = 'renew_article';
                    $params['Type'] = 'detail2';
                    $params['Code'] = $code;
                    return $params;
                }
            }
            else
            {
                $params['Pattern'] = 'renew_article';
                $params['Type'] = 'detail2';
                $params['Code'] = $e;
                return $params;
            }
        }
        // http://xxx.com/todoufuken/shiku/kodawari/2/bxxx
        if (substr($f, 0, 1) == 'b')
        {
            $code = substr($f, 1);
            if (ereg("^[0-9]+$", $code))
            {

                // 物件詳細
                if (isset($g) && !empty($g))
                {
                    $params['Pattern'] = 'renew_detail';
                    $params['Type'] = 'detail2';
                    $params['Code'] = $g;
                    return $params;
                }
                // 建物詳細
                else
                {
                    $params['Pattern'] = 'renew_article';
                    $params['Type'] = 'detail2';
                    $params['Code'] = $code;
                    return $params;
                }
            }
            else
            {
                $params['Pattern'] = 'renew_article';
                $params['Type'] = 'detail2';
                $params['Code'] = $f;
                return $params;
            }
        }
        // ★★★建物詳細静的ページ

        // ★★★複数地域か駅を選択すると→希望条件ページ転移
        if ($method == 'POST' && $b == 'area' && $c == 'hope')
        {
            $params['Pattern'] = 'renew_hope';
            return $params;
        }
        // ★★★複数地域か駅を選択すると→希望条件ページ転移

        // ★★★物件一覧から→町探しページ転移
        if ($method == 'POST' && $b == 'area' && $c == 'town')
        {
            $params['Pattern'] = 'renew_town';
            return $params;
        }
        // ★★★物件一覧から→町探しページ転移

        // ★★★Ajax呼ぶ
        if ($b == 'areaajax')
        {
            $params['Pattern'] = 'renew_areaajax';
            $params['AMethod'] = $c; // メソッド名
            return $params;
        }
        // ★★★Ajax呼ぶ

        // ★★★トップモーダル
        if ($b == 'topmodal' && $c == 'modal')
        {
            $params['Pattern'] = 'renew_modal';
            return $params;
        }
        // ★★★トップモーダル
        // ★★★検討リスト
        if ($b == 'user')
        {
            if ($c == 'study')
            {
                $params['Pattern'] = 'renew_study';
            }
            else if ($c == 'recent')
            {
                $params['Pattern'] = 'renew_recent';
            }
            else if ($c == 'favoritelist')
            {
                $params['Pattern'] = 'renew_favoritelist';
            }

            return $params;
        }
        // ★★★検討リスト

        // 通勤通学検索 add jschoi 20141217
        if ($b == 'search')
        {
            // 簡単検索じゃない
            if ($c == 'tsukintsugakujikansearch')
            {
                $params['Pattern'] = 'renew_search';
                $params['Method'] = $c;
                return $params;
            }
            else if ($c == 'requestsearch')
            {

                // 2015/01/30 簡単リクエストへ戻すための作業 start
                // $params['Pattern'] = 'renew_requestsearch';
                // $params['Method'] = $d;

                // if($d == "regist")
                // $params['Pattern'] = "renew_requestsearh_regist";
                // 2015/01/30 簡単リクエストへ戻すための作業 end

                return $params;
            }
        }
        // 通勤通学検索

        // ショップ詳細
        if ($b == 'shop')
        {
            if (ereg('^[0-9]+$', $c))
            {
                $params['Pattern'] = 'renew_shopdetail';
                $params['Code'] = $c;
                return $params;
            }
        }

        // ★★★タイプ、こだわり
        if ($b == "apart" || $b == "mansion" || $b == "kodate" || $b == "kodawari")
        {
            if ($b == "apart")
            {
                $params['syubetu1'] = 'on';
            }
            else if ($value[1] == "mansion")
            {
                $params['syubetu2'] = 'on';
            }
            else if ($value[1] == "kodate")
            {
                $params['syubetu3'] = 'on';
            }
            if ($b == "kodawari")
            {
                $params['Category'] = $d;
            }
            else
            {
                $params['Category'] = $c;
            }

            $params['conditions'] = preg_split('@/@', $ar_url[0], NULL, PREG_SPLIT_NO_EMPTY);
            $params['Pattern'] = 'renew_othersearch';
            return $params;
        }
        // ★★★タイプ、こだわり

        if (in_array($b, Apm_Config_Search::$TODOUFUKEN_NAME_CODE_LIST))
        {
            if ($c == 'chiiki')
            {
                $params['Pattern'] = 'renew_area';
                $params['Area'] = $b;
                return $params;
            }

            // ★★★都道府県の路線
            if ($c == 'station')
            {
                $params['Pattern'] = 'renew_area';
                $params['Area'] = $b;
                $params['Category'] = 'line';
                return $params;
            }
            // ★★★都道府県のショップ
            if ($c == 'shop')
            {
                $params['Pattern'] = 'renew_shopsearch';
                $params['Area'] = $b;
                $params['Category'] = $d;
                return $params;
            }
            // ★★★都道府県の地域か路線

            if (ereg("^[0-9]+$", $c))
            {
                $clen = strlen($c);
                if ($clen == 4)
                { // ★★★路線
                    $params['Pattern'] = 'renew_area';
                    $params['Area'] = $b;
                    $params['Category'] = 'line';
                    $params['RailCd'] = $c;
                    // ★★★希望条件
                    if ($d == "hope")
                    {
                        $params['Pattern'] = 'renew_hope';
                    }
                    // ★★★希望条件
                    return $params;
                }
                if ($clen == 3)
                { // ★★★市区町村
                    $params['Pattern'] = 'renew_list';
                    $code = array_search($b, Apm_Config_Search::$TODOUFUKEN_NAME_CODE_LIST);
                    $params['Area'] = 'area';
                    $params['Code'] = $code . '-' . $code . $c;
                    $params['SrhKbn'] = '01';
                    // $params['Page'] = $e ? $e : 1;
                    $params['Page'] = 1;
                    // ★★★希望条件
                    if ($d == "hope")
                    {
                        $params['Pattern'] = 'renew_hope';
                    }
                    // ★★★希望条件

                    // ★★★こだわり
                    if ($d == "apart" || $d == "mansion" || $d == "kodate" || $d == "kodawari")
                    {
                        if ($d != "kodawari")
                        {
                            $params['KodawariId'] = $d;
                        }
                        else
                        {
                            $params['KodawariId'] = $e;
                        }
                    }
                    // ★★★こだわり

                    return $params;
                }
                if ($clen == 7)
                { // ★★★駅
                    $params['Pattern'] = 'renew_list';
                    $code = array_search($b, Apm_Config_Search::$TODOUFUKEN_NAME_CODE_LIST);
                    $params['Area'] = 'line';
                    $params['Code'] = $code . '-' . $c;
                    $params['SrhKbn'] = '02';
                    $params['Page'] = $e ? $e : 1;
                    $params['Page'] = 1;
                    // ★★★希望条件
                    if ($d == "hope")
                    {
                        $params['Pattern'] = 'renew_hope';
                    }
                    // ★★★希望条件

                    // ★★★こだわり
                    if ($d == "apart" || $d == "mansion" || $d == "kodate" || $d == "kodawari")
                    {
                        if ($d != "kodawari")
                        {
                            $params['KodawariId'] = $d;
                        }
                        else
                        {
                            $params['KodawariId'] = $e;
                        }
                    }
                    // ★★★こだわり

                    return $params;
                }
                if ($clen == 6)
                { // ★★★町
                    $params['Pattern'] = 'renew_list';
                    $code = array_search($b, Apm_Config_Search::$TODOUFUKEN_NAME_CODE_LIST);
                    $params['Area'] = 'area';
                    $params['SrhKbn'] = '01';
                    $params['Code'] = $code . '-' . $code . substr($c, 0, 3);
                    $params['TownCd'][] = $code . $c;
                    // $params['Page'] = $e ? $e : 1;
                    $params['Page'] = 1;

                    // ★★★こだわり
                    if ($d == "apart" || $d == "mansion" || $d == "kodate" || $d == "kodawari")
                    {
                        if ($d != "kodawari")
                        {
                            $params['KodawariId'] = $d;
                        }
                        else
                        {
                            $params['KodawariId'] = $e;
                        }
                    }
                    // ★★★こだわり

                    return $params;
                }
                if ($clen == 5)
                { // ショップ
                    $params['Pattern'] = 'renew_shoplist';
                    $params['Category'] = 'area';
                    $params['Code'] = $c;
                    return $params;
                }
            }
        }
    }
    if ($b == "inquiry" && ($method == 'GET' || $method == 'POST'))
    {
        if ($c == 'bukkenentry' && $vlen >= 5)
        {
            $params['Pattern'] = 'renew_bukkenentry';
            $params['BukkenCd'] = $d;
            $params['Step'] = $e;
            return $params;
        }
        elseif ($c == 'bukkenentry2' && $vlen >= 4)
        {
            $params['Pattern'] = 'renew_bukkenentry2';
            $params['Step'] = $d;
            return $params;
        }
        elseif ($c == 'shopentry' && $vlen >= 5)
        {
            $params['Pattern'] = 'renew_shopentry';
            $params['ShopCd'] = $d;
            $params['Step'] = $e;
            return $params;
        }
        elseif ($c == 'claimentry')
        {
            $params['Pattern'] = 'renew_claimentry';
            return $params;
        }
        // 20141211 S_Add
        elseif ($c == 'archentry')
        {
            $params['Pattern'] = 'renew_archentry';
            $params['TatemonoCd'] = $d;
            $params['Step'] = $e;
            return $params;
        }
        elseif ($c == 'etccnf')
        {
            $params['Pattern'] = 'renew_etccnf';
            $params['Step'] = $d;
            return $params;
        }
        // 20141211 E_Add
        // 20141218 S_Add
        elseif ($c == 'conditionsentry')
        {
            $params['Pattern'] = 'renew_conditionsentry';
            $params['Step'] = $d;
            return $params;
        }
        // 20141218 E_Add
    }

    // ------------------------------------------------------------------------

    // URL分割
    $value = split('/', $ar_url[0]);
    // 先頭の空配列を削除
    array_shift($value);

    // **固定URLチェック**
    /*
     * 物件詳細(detail)
     */
    if ($value[0] == 'detail' && isset($value[1]) && is_numeric($value[1]))
    {
        $params['Pattern'] = 'detail';
        $params['Category'] = '0';
        $params['ID'] = $value[1]; // 物件CD
        $params['buken_static'] = 1;
        return $params;
    }

    /*
     * 物件詳細(rstdtl)
     */
    if ($value[0] == 'rstdtl' && isset($value[1]) && $value[1] == 'bukendtl' && !empty($value[2]))
    {
        $params['Pattern'] = 'detail';
        $params['ID'] = $value[2]; // 物件CD
        $params['SrhKbn'] = $value[3]; // 検索区分
        if ($value[4] != 0)
        {
            $params['OemCd'] = $value[4]; // OEM
        }
        if ($value[5] != 0)
        {
            $params['ComId'] = $value[5]; // 法人
        }
        $params['buken_static'] = 0;
        return $params;
    }

    /*
     * 物件問い合わせ(通常)
     */

    if ($value[0] == 'inquiry' && isset($value[1]) && $value[1] == 'bukkenentry' && !empty($value[2]))
    {
        $params['Pattern'] = 'inquiry_b';
        $params['BukkenCd'] = $value[2]; // 物件CD
        $params['SrhKbn'] = $value[3]; // 検索区分
        if ($value[4] != 0)
        {
            $params['OemCd'] = $value[4]; // OEM
        }
        if ($value[5] != 0)
        {
            $params['ComId'] = $value[5]; // 法人
        }
        return $params;
    }

    /*
     * 物件問い合わせ(法人)
     */
    if ($value[0] == 'inquiry' && isset($value[1]) && $value[1] == 'asmemberentry' && !empty($value[2]))
    {
        $params['Pattern'] = 'inquiry_a';
        $params['ID'] = $value[2]; // 物件CD
        $params['SrhKbn'] = $value[3]; // 検索区分
        if ($value[4] != 0)
        {
            $params['OemCd'] = $value[4]; // OEM
        }
        if ($value[5] != 0)
        {
            $params['ComId'] = $value[5]; // 法人
        }
        return $params;
    }

    /*
     * 店舗詳細
     */

    if ($value[0] == 'shop' && isset($value[1]) && is_numeric($value[1]))
    {
        $params['Pattern'] = 'shop_detail';
        $params['Category'] = '0';
        $params['ShopCd'] = $value[1]; // 店舗CD
        if (empty($params['SrhKbn'])) $params['SrhKbn'] = Apm_Config_Shop::SEARCH_KUBUN_MAP;
        if (empty($params['SrhType'])) $params['SrhType'] = Apm_Config_Shop::SEARCH_TYPE_CITY;
        return $params;
    }

    /*
     * 災害時住宅支援
     */
    // if ($value[0] == 'sienjyutaku') {
    // $params['Pattern'] = 'kodawari';
    // $params['Category'] = '1';
    // $params['KodawariId'] = '38';
    // $params['SrhKbn'] = Apm_Config_Search::SRHKBN_KODAWARI;
    // return $params;
    // }

    /*
     * 加盟店サイト
     */
    if ($value[0] == 'membersite' && isset($value[1]) && is_numeric($value[1]))
    {
        $params['Pattern'] = 'shop_detail';
        $params['Category'] = '9';
        $params['ShopCd'] = $value[1]; // 店舗CD
        if (isset($value[2]) && is_numeric($value[2]))
        {
            $params['page'] = $value[2];
        }
        return $params;
    }

    // **旧URL転送**
    $new_url = '';
    /*
     * タイプ
     */
    if ($value[0] == 'type')
    {
        $new_url = substr($ar_url[0], 5); // /type削除
    }
    /*
     * エリア
     */
    if ($value[0] == 'chiiki')
    {
        // エリアCat1
        if (empty($value[2]) || $value[2] == 'index.html')
        {
            if ($value[1] == Apm_Config_Search::$AREA_NAME_CODE_LIST['01'])
            {
                // 北海道の場合
                $new_url = $value[1] . '/chiiki/';
            }
            else
            {
                $new_url = $value[1];
            }
        } // エリアCat2
        elseif (preg_match('/^([a-z]+)$/', $value[2]) || preg_match('/^([a-z]+)\.html$/', $value[2]))
        {
            $value2 = str_replace('.html', '', $value[2]);
            $new_url = $value2 . '/chiiki/';
        } // エリアCat2.5／エリアCat3
        elseif (preg_match('/^([a-z]+)-([0-9a-z]+)$/', $value[2]) || preg_match('/^([a-z]+)-([0-9a-z]+)-([0-9]+)-([0-9]+)-([0-9]+)$/', $value[2]))
        {
            $value2 = split('-', $value[2]);
            $new_url = '/' . $value2[0] . '/' . $value2[1] . '/';
            if (!empty($value2[2]) && !empty($value2[3]) && !empty($value2[4]))
            {
                // ページ、他
                if ($value2[2] == Apm_Config_Search::LISTTYPE_DEFAULT && $value2[3] == Apm_Config_Search::SORTCD_DEFAULT)
                {
                    if ($value2[4] != '1') $new_url .= $value2[4] . '/'; // デフォルト
                }
                else
                {
                    $new_url .= $value2[4] . '-' . $value2[2] . '-' . $value2[3] . '/';
                }
            }
        } // エリアCat3.5
        elseif (preg_match('/^([a-z]+)-([0-9]+)-more-([0-9]+)$/', $value[2]))
        {
            $value2 = split('-', $value[2]);
            $new_url = '/' . $value2[0] . '/' . $value2[1] . '-more/' . $value2[3] . '/';
        } // エリアCat4
        elseif (preg_match('/^([a-z]+)-([0-9]+)-([0-9a-zA-Z]+)$/', $value[2]) || preg_match('/^([a-z]+)-([0-9]+)-([0-9a-zA-Z]+)-([0-9]+)-([0-9]+)-([0-9]+)$/', $value[2]))
        {
            $value2 = split('-', $value[2]);
            $new_url = '/' . $value2[0] . '/' . $value2[1] . '-' . $value2[2] . '/';
            if (!empty($value2[3]) && !empty($value2[4]) && !empty($value2[5]))
            {
                // ページ、他
                if ($value2[3] == Apm_Config_Search::LISTTYPE_DEFAULT && $value2[4] == Apm_Config_Search::SORTCD_DEFAULT)
                {
                    if ($value2[5] != '1') $new_url .= $value2[5] . '/'; // デフォルト
                }
                else
                {
                    $new_url .= $value2[5] . '-' . $value2[3] . '-' . $value2[4] . '/';
                }
            }
        }
    }
    /*
     * 沿線・駅
     */
    if ($value[0] == 'station' && !empty($value[1]))
    {
        if (preg_match('/^([a-z]+)$/', $value[1]))
        {
            $new_url = substr($ar_url[0], 8); // /station削除
            if (empty($value[2]))
            {
                $new_url .= 'station/';
            }
        }
        elseif (preg_match('/^([a-z]+)-([0-9]+)$/', $value[1]) || preg_match('/^([a-z]+)-([0-9]+)-([0-9]+)-([0-9]+)-([0-9]+)$/', $value[1]))
        {
            $value2 = split('-', $value[1]);
            $new_url = '/' . $value2[0] . '/' . $value2[1] . '/';
            if (!empty($value2[2]) && !empty($value2[3]) && !empty($value2[4]))
            {
                // ページ、他
                if ($value2[2] == Apm_Config_Search::LISTTYPE_DEFAULT && $value2[3] == Apm_Config_Search::SORTCD_DEFAULT)
                {
                    if ($value2[4] != '1') $new_url .= $value2[4] . '/'; // デフォルト
                }
                else
                {
                    $new_url .= $value2[4] . '-' . $value2[2] . '-' . $value2[3] . '/';
                }
            }
        }
    }
    /*
     * x3
     */
    if ($value[0] == 'x3' && !empty($value[1]) && preg_match('/^([0-9]+)-([0-9]+)$/', $value[1]))
    {
        $value2 = split('-', $value[1]);
        $typeCd = array_search($value2[0], Apm_Config_Search::$TATEMONO_SYUBETU_ID_LIST);
        $kodawariId = $value2[1];
        $new_url = '/kodawari/' . $kodawariId . '/' . $typeCd . '/';
    }
    /*
     * x2,4,5
     */
    if (($value[0] == 'x2' || $value[0] == 'x4' || $value[0] == 'x5') && !empty($value[1]))
    {
        $value2 = split('-', $value[1]);
        // 住居形態・こだわりを抽出
        $front_url = '';
        if ($value[0] == 'x2')
        {
            // 住居形態
            $front_url = '/' . array_search($value2[0], Apm_Config_Search::$TATEMONO_SYUBETU_ID_LIST);
            array_shift($value2); // typeCd
        }
        elseif ($value[0] == 'x4')
        {
            // こだわり
            $front_url = '/kodawari/' . $value2[0];
            array_shift($value2); // kodawariId
        }
        elseif ($value[0] == 'x5')
        {
            // 住居形態xこだわり
            $front_url = '/kodawari/' . $value2[1] . '/' . array_search($value2[0], Apm_Config_Search::$TATEMONO_SYUBETU_ID_LIST);
            array_shift($value2); // typeCd
            array_shift($value2); // kodawariId
        }
        $front_url .= '/';
        // エリア抽出
        $back_url = '';
        if (empty($value2[1]))
        {
            // エリアCat1
            $back_url .= $value2[0] . '/';
        }
        else
        {
            // エリアCat2
            $back_url .= $value2[1] . '/';
        }
        if (!empty($value2[2]))
        {
            // エリアCat2.5 or 3
            $back_url .= $value2[2];
        }
        if (!empty($value2[3]))
        {
            if ($value2[3] == 'more')
            {
                // エリアCat3.5
                $back_url .= '-more/' . $value2[4];
            }
            else if (count($value2) == 6)
            {
                // エリアCat3(2ページ目以降)
                if ($value2[3] == Apm_Config_Search::LISTTYPE_DEFAULT && $value2[4] == Apm_Config_Search::SORTCD_DEFAULT)
                {
                    if ($value2[5] != '1') $back_url .= $value2[5] . '/'; // デフォルト
                }
                else
                {
                    $back_url .= '/' . $value2[5] . '-' . $value2[3] . '-' . $value2[4];
                }
            }
            else
            {
                // エリアCat4
                $back_url .= '-' . $value2[3];
                if (count($value2) == 7)
                {
                    // エリアCat4(2ページ目以降)
                    if ($value2[4] == Apm_Config_Search::LISTTYPE_DEFAULT && $value2[5] == Apm_Config_Search::SORTCD_DEFAULT)
                    {
                        if ($value2[6] != '1') $back_url .= $value2[6] . '/'; // デフォルト
                    }
                    else
                    {
                        $back_url .= '/' . $value2[6] . '-' . $value2[4] . '-' . $value2[5];
                    }
                }
            }
        }
        // URL結合
        if (!empty($back_url))
        {
            $new_url = $front_url . $back_url;
        }
    }
    /*
     * x2s,4s,5s
     */
    if (($value[0] == 'x2s' || $value[0] == 'x4s' || $value[0] == 'x5s') && !empty($value[1]))
    {
        $value2 = split('-', $value[1]);
        // 住居形態・こだわりを抽出
        $front_url = '';
        if ($value[0] == 'x2s')
        {
            // 住居形態
            $front_url = '/' . array_search($value2[0], Apm_Config_Search::$TATEMONO_SYUBETU_ID_LIST);
            array_shift($value2); // typeCd
        }
        elseif ($value[0] == 'x4s')
        {
            // こだわり
            $front_url = '/kodawari/' . $value2[0];
            array_shift($value2); // kodawariId
        }
        elseif ($value[0] == 'x5s')
        {
            // 住居形態xこだわり
            $front_url = '/kodawari/' . $value2[1] . '/' . array_search($value2[0], Apm_Config_Search::$TATEMONO_SYUBETU_ID_LIST);
            array_shift($value2); // typeCd
            array_shift($value2); // kodawariId
        }
        $front_url .= '/';
        // 駅抽出
        $back_url = '';
        if (!empty($value2[0]) && !empty($value2[1]))
        {
            $back_url .= $value2[0] . '/' . $value2[1] . '/';
            if (count($value2) == 5)
            {
                // ページ、他
                if ($value2[2] == Apm_Config_Search::LISTTYPE_DEFAULT && $value2[3] == Apm_Config_Search::SORTCD_DEFAULT)
                {
                    if ($value2[4] != '1') $back_url .= $value2[4] . '/'; // デフォルト
                }
                else
                {
                    $back_url .= $value2[4] . '-' . $value2[2] . '-' . $value2[3] . '/';
                }
            }
        }
        // URL結合
        if (!empty($back_url))
        {
            $new_url = $front_url . $back_url;
        }
    }

    // shop 既存URIとぶつかるためリダイレクト中止
    /*
     * if ($value[0] == 'shop' && $value[1] == 'redirect') { $new_url =
     * str_replace('/shop/redirect', '', $ar_url[0]); } if ($value[0] == 'shop' && $value[1] ==
     * 'selcity') { // 都道府県 $prefCd = "00"; $prefCnt = 0; foreach ($params as $key => $val) { if
     * (preg_match('/^PrefCd(.*)$/', $key)) { $prefCd = $val; $prefCnt++; } } $prefNm = ""; if
     * ($prefCnt == 1) $prefNm = Apm_Config_Search::$TODOUFUKEN_NAME_CODE_LIST[$prefCd]; if
     * (!empty($prefNm)) { $new_url = '/shop/redirect/'.$prefNm.'/shop'; if (!empty($ar_url[1]))
     * unset($ar_url[1]);	// パラメータ削除 } } if ($value[0] == 'shop' && $value[1] == 'rstshoplist' &&
     * $params['SrhKbn'] == '1' && $params['SrhType'] == '1' && $params['tokucho01'] == '1') { //
     * 特徴チェック $tokucho = true; foreach ($params as $key => $val) { $matches = array(); if
     * (preg_match('/^tokucho([0-9]+)$/', $key, $matches)) { if ($matches[1] != '01' && $val == '1')
     * { $tokucho = false; } } } if ($tokucho) { // 都道府県・市区町村 $prefCd = "00"; $cityCd = "00000";
     * $cityCnt = 0; foreach ($params as $key => $val) { if (preg_match('/^CityCd(.*)$/', $key)) {
     * $cityCd = $val; $cityCnt++; } } if ($cityCnt == 1 && strlen($cityCd) == 5) { $prefCd =
     * substr($cityCd, 0, 2); } $prefNm = Apm_Config_Search::$TODOUFUKEN_NAME_CODE_LIST[$prefCd]; if
     * (!empty($prefNm) && $cityCd != "00000") { $new_url =
     * '/shop/redirect/'.$prefNm.'/'.$cityCd.'/'; if (!empty($ar_url[1])) unset($ar_url[1]);	//
     * パラメータ削除 } } }
     */

    if (!empty($new_url))
    {
        // URL補助
        if (substr($new_url, 0, 1) != '/') $new_url = '/' . $new_url;
        if (substr($new_url, -1) != '/') $new_url = $new_url . '/';
        // パラメータ付与
        if (!empty($ar_url[1])) $new_url .= '?' . $ar_url[1];
        // 301リダイレクト
        __log_debug_ex("URL転送：" . $new_url);
        header("HTTP/1.1 301 Moved Permanently");
        header("Location: " . $new_url);
        header("x-pass-through:true");
        exit();
    }

    // **静的URLチェック**
    /*
     * こだわり
     */
    if ($value[0] == 'kodawari')
    {
        if (isset($value[1]) && is_numeric($value[1]))
        {
            // こだわりIDセット
            $params['KodawariId'] = $value[1];
            $params['Category'] = '1';
            // valueをシフト
            array_shift($value); // kodawari
            array_shift($value); // KodawariId
        }
        else
        {
            // こだわりTOP
            $params['Category'] = '0';
            // valueをシフト
            array_shift($value); // kodawari
        }
        $kodawariFlag = true;
    }

    /*
     * タイプ
     */
    if (array_key_exists($value[0], Apm_Config_Search::$TATEMONO_SYUBETU_ID_LIST))
    {
        // 建物種別CDセット
        $params['TatemonoTypeCd'] = Apm_Config_Search::$TATEMONO_SYUBETU_ID_LIST[$value[0]];
        $params['Category'] = '0';
        // valueをシフト
        array_shift($value); // TatemonoType
        $typeFlag = true;
    }

    /*
     * 都道府県
     */
    if (in_array($value[0], Apm_Config_Search::$TODOUFUKEN_NAME_CODE_LIST))
    {
        // 都道府県CDセット
        $params['PrefCd'][] = array_search($value[0], Apm_Config_Search::$TODOUFUKEN_NAME_CODE_LIST);
        $params['PrefName'] = $value[0];
        $params['first_check'] = $params['PrefCd'][0];
        $params['Category'] = '2';
        // valueをシフト
        array_shift($value); // PrefName
        $prefFlag = true;
    } /*
       * エリア
       */
    elseif (in_array($value[0], Apm_Config_Search::$AREA_NAME_CODE_LIST))
    {
        // エリアCDセット
        $params['AreaCd'] = array_search($value[0], Apm_Config_Search::$AREA_NAME_CODE_LIST);
        $params['AreaName'] = $value[0];
        $params['Category'] = '1';
        // valueをシフト
        array_shift($value); // AreaName
        $areaFlag = true;
    }

    /*
     * 沿線・駅検索
     */
    if ($value[0] == 'station')
    {
        // valueをシフト
        array_shift($value); // station
        $stationFlag = true;
    }

    /*
     * 地域
     */
    if ($value[0] == 'chiiki')
    {
        // valueをシフト
        array_shift($value); // chiki
        $chikiFlag = true;
    }

    /*
     * 店舗
     */
    if ($value[0] == 'shop')
    {
        // valueをシフト
        array_shift($value); // shop
        $shopFlag = true;
        // 通常アクションの場合
        if (!empty($value[0])) return array();
    }
    /*
     * 政令指定都市
     */
    if (in_array($value[0], Apm_Config_Search::$SITEITOSI_ROMAN_LIST))
    {
        // 政令指定都市CDセット
        $params['SiteitosiCd'][] = array_search($value[0], Apm_Config_Search::$SITEITOSI_ROMAN_LIST);
        $params['SiteitosiName'] = $value[0];
        $params['Category'] = '2.5';
        // valueをシフト
        array_shift($value); // SiteitosiName
    } /*
       * エリアCat3.5
       */
    elseif (preg_match('/^([0-9]+)-more$/', $value[0]))
    {
        $value2 = split('-', $value[0]);
        // 市区町村CDセット
        $params['CityCd'][] = $params['PrefCd'][0] . $value2[0];
        $params['OrgCityCd'] = $value2[0];
        $params['page'] = 1;
        $params['CityMore'] = 1;
        $params['Category'] = '3.5';
        // valueをシフト
        array_shift($value); // CityCd-more
    } /*
       * 沿線・駅Cat2.5l
       */
    elseif (preg_match('/^([0-9]+)-list$/', $value[0]))
    {
        $value2 = split('-', $value[0]);
        // 市区町村CDセット
        $params['RailCd'][] = $value2[0];
        $params['Category'] = '2.5l';
        $stationFlag = true;
        // valueをシフト
        array_shift($value); // RailCd-list
    } /*
       * 町域
       */
    elseif (preg_match('/^([0-9]+)-([0-9a-zA-Z]+)$/', $value[0]))
    {
        $value2 = split('-', $value[0]);
        // 市区町村・町域CDセット
        $params['CityCd'][] = $params['PrefCd'][0] . $value2[0];
        $params['OrgCityCd'] = $value2[0];
        $params['TownCd'][] = $params['PrefCd'][0] . $value2[0] . $value2[1];
        $params['OrgTownCd'] = $value2[1];
        $params['Category'] = '4';
        // valueをシフト
        array_shift($value); // CityCd-TownCd
    } /*
       * 市区町村／沿線／駅／店舗市区町村
       */
    elseif (is_numeric($value[0]))
    {
        switch (strlen($value[0]))
        {
            case 3: // 市区町村
                    // 市区町村CDセット
                $params['CityCd'][] = $params['PrefCd'][0] . $value[0];
                $params['OrgCityCd'] = $value[0];
                $params['Category'] = '3';
                break;
            case 4: // 沿線
                    // 沿線CDセット
                $params['RailCd'][] = $value[0];
                if ($prefFlag)
                    $params['Category'] = '2.5';
                else $params['Category'] = '2';
                $stationFlag = true;
                break;
            case 7: // 駅
                    // 駅CDセット
                $params['RailCd'][] = substr($value[0], 0, 4); // 駅CDを分割して沿線CDへ
                $params['StCd'][] = $value[0];
                $params['Category'] = '3';
                $stationFlag = true;
                break;
            case 5: // 店舗市区町村(都道府県CD+市区町村CD)
                    // 市区町村CDセット
                $params['CityCd'][] = $value[0];
                $params['Category'] = '3';
                $shopFlag = true;
                break;
        }
        // valueをシフト
        array_shift($value);
    }

    /*
     * ページ-タブ-ソート
     */
    if (preg_match('/^([0-9]+)$/', $value[0]) || preg_match('/^([0-9]+)-([0-9]+)-([0-9]+)$/', $value[0]))
    {
        $value2 = split('-', $value[0]);
        // パラメータセット
        if (!empty($value2[2]))
        {
            $params['RstobiDispType'] = $value2[1];
            $params['SortCd'] = $value2[2];
            if ($params['RstobiDispType'] == Apm_Config_Search::LISTTYPE_SHOP)
            {
                $params['shop_page'] = $value2[0];
            }
            else
            {
                $params['page'] = $value2[0];
            }
        }
        else
        {
            $params['page'] = $value2[0];
        }
        if (!empty($params['CityMore'])) $params['CityMore'] = $params['page'];
        // valueをシフト
        array_shift($value);
    }

    // **パターン割り出し**
    // 店舗検索
    if ($shopFlag)
    {
        $params['Pattern'] = 'shop';
        if (empty($params['Category']))
        {
            $params['Category'] = '0';
        }
        else
        {
            $params['SrhKbn'] = Apm_Config_Shop::SEARCH_KUBUN_MAP;
            $params['SrhType'] = Apm_Config_Shop::SEARCH_TYPE_CITY;
        }
    } // 沿線・駅検索
    elseif ($stationFlag)
    {
        if ($params['Category'] == '3')
        {
            // 沿線・駅Cat3
            if ($typeFlag && $kodawariFlag)
                $params['Pattern'] = 'x5s';
            elseif ($typeFlag)
                $params['Pattern'] = 'x2s';
            elseif ($kodawariFlag)
                $params['Pattern'] = 'x4s';
            else $params['Pattern'] = 'station';
        }
        else
        {
            $params['Pattern'] = 'station';
            if (empty($params['Category']))
            {
                if ($prefFlag)

                    // 沿線・駅Cat1
                    $params['Category'] = '1';
                else                 // 沿線・駅TOP
                $params['Category'] = '0';
            }
        }
        $params['SrhKbn'] = Apm_Config_Search::SRHKBN_ENSENEKI;
    }
    elseif ($areaFlag || $prefFlag || $typeFlag || $kodawariFlag)
    {
        if ($typeFlag && $kodawariFlag)
        {
            if ($areaFlag || $prefFlag)
            {
                // 住居形態xエリアxこだわり
                $params['Pattern'] = 'x5';
            }
            else
            {
                // 住居形態xこだわり
                $params['Pattern'] = 'x3';
                $params['Category'] = '1';
            }
            $params['SrhKbn'] = Apm_Config_Search::SRHKBN_JYUKYOKEITAI;
        }
        else if ($typeFlag)
        {
            // 住居形態検索
            if ($areaFlag || $prefFlag)
                $params['Pattern'] = 'x2';
            else $params['Pattern'] = 'type';
            $params['SrhKbn'] = Apm_Config_Search::SRHKBN_JYUKYOKEITAI;
        }
        else if ($kodawariFlag)
        {
            // こだわり検索
            if ($areaFlag || $prefFlag)
                $params['Pattern'] = 'x4';
            else $params['Pattern'] = 'kodawari';
            $params['SrhKbn'] = Apm_Config_Search::SRHKBN_KODAWARI;
        }
        else
        {
            // 住所検索
            $params['Pattern'] = 'chiiki';
            if ($params['Category'] == '2' && !$chikiFlag) $params['Category'] = '1.5';
            if ($params['Category'] == '1' || $params['Category'] == '1.5')
                $params['SrhKbn'] = Apm_Config_Search::SRHKBN_AREA;
            else $params['SrhKbn'] = Apm_Config_Search::SRHKBN_JYUSYO;
        }
    }

    return $params;
}

function __get_parameters_by_url_for_sp($url, $method)
{
    $url = substr($url, 3);

    $params = array();
    $value = array();
    $value2 = array();

    $kodawariFlag = false;
    $typeFlag = false;
    $areaFlag = false;
    $prefFlag = false;
    $stationFlag = false;
    $chikiFlag = false;
    $shopFlag = false;

    // パラメータをセット
    $ar_params = '';
    $ar_url = explode('?', $url);
    $ar_params = explode('&', $ar_url[1]);
    if (is_array($ar_params))
    {
        foreach ($ar_params as $key => $val)
        {
            if (!empty($val))
            {
                $ar_val = explode('=', $val);
                $params[$ar_val[0]] = $ar_val[1];
            }
        }
    }
    $request_params = array_merge($_POST, $_GET);
    $request_SrhKbn = $request_params['SrhKbn'];

    // ------------------------------------------------------------------------

    if ($url == '/test/')
    {
        $params['Pattern'] = 'mobileapi_test';
        return $params;
    }

    if ($url == '/' || ereg("^/top/", $url) || ereg("^/index(.*)", $url) || ereg("^/\?(.*)", $url))
    {
        $value = split('/', $url);
        $params['Pattern'] = 'mobileapi_top';
        $params['Category'] = $value[2];
        return $params;
    }

    $value = split('/', $ar_url[0]);
    $vlen = count($value);

    if ($vlen >= 5)
    {
        if ($value[1] == "apart")
        {
            $vlen--;
            array_shift($value);
            $params['syubetu1'] = 'on';
        }
        else if ($value[1] == "mansion")
        {
            $vlen--;
            array_shift($value);
            $params['syubetu2'] = 'on';
        }
        else if ($value[1] == "kodate")
        {
            $vlen--;
            array_shift($value);
            $params['syubetu3'] = 'on';
        }
    }

    $a = array_shift($value);
    $b = array_shift($value);
    $c = array_shift($value);

    if ($vlen == 3)
    {

        // エラー
        if ($b == '404')
        {
            $params['Pattern'] = 'mobileapi_404';
            return $params;
        }
        if ($b == '500')
        {
            $params['Pattern'] = 'mobileapi_500';
            return $params;
        }

        // ※TODOUFUKEN_NAMEを先にチェックすることに注意.
        // AREA_NAMEを先にチェックすると /hokkaido/ をtopにルーティングしてしまう.
        if (in_array($b, Apm_Config_Search::$TODOUFUKEN_NAME_CODE_LIST))
        {
            $params['Pattern'] = 'mobileapi_area';
            $params['Area'] = $b;
            return $params;
        }
        if (in_array($b, Apm_Config_Search::$AREA_NAME_CODE_LIST))
        {
            $params['Pattern'] = 'mobileapi_top';
            $params['Category'] = $b;
            return $params;
        }
        if ($b == 'shop' && ereg('^rstshoplist', $c) && array_key_exists("SrhType", $params))
        {
            $params['Pattern'] = 'mobileapi_shoplist';
            $typ = $params['SrhType'];
            if ($typ == 1) $params['Category'] = 'area2';
            if ($typ == 2) $params['Category'] = 'line';
            return $params;
        }
        if ($method == 'POST' && $b == 'rstobi' && $c == 'rstobi' && !array_key_exists('OemCd', $request_params) && !array_key_exists('ComId', $request_params) && $request_SrhKbn != Apm_Config_Search::SRHKBN_ROSENZU && $request_SrhKbn != Apm_Config_Search::SRHKBN_TUKINTUGAKU && $request_SrhKbn != Apm_Config_Search::SRHKBN_SUMITAIEKI && $request_SrhKbn != Apm_Config_Search::SRHKBN_FREEWORD && $request_SrhKbn != Apm_Config_Search::SRHKBN_YACHINSOUBA && $request_SrhKbn != Apm_Config_Search::SRHKBN_CHINRYOMADORI && $request_SrhKbn != Apm_Config_Search::SRHKBN_GAKKONAME)
        {
            $params['Pattern'] = 'mobileapi_list';
            return $params;
        }

        // Ajax呼ぶ
        if ($b == 'areaajax')
        {
            $params['Pattern'] = 'mobileapi_areaajax';
            $params['AMethod'] = $c; // メソッド名
            return $params;
        }
        // Ajax呼ぶ

        // 20141220 S_Add
        // Ajax呼ぶ　条件問い合わせ検索
        if ($b == 'conditionsajax')
        {
            $params['Pattern'] = 'mobileapi_conditionsajax';
            $params['AMethod'] = $c; // メソッド名
            return $params;
        }
        // 20141220 E_Add

        // ★★★物件一覧から→町探しページ転移
        if ($method == 'POST' && $c == 'town')
        {
            $params['Pattern'] = 'mobileapi_town';
            return $params;
        }
        if ($method == 'POST' && $c == 'areachange')
        {
            $params['Pattern'] = 'mobileapi_areachange';
            return $params;
        }
        if ($method == 'POST' && $c == 'linechange')
        {
            $params['Pattern'] = 'mobileapi_linechange';
            return $params;
        }
        if ($method == 'POST' && $c == 'ekichange')
        {
            $params['Pattern'] = 'mobileapi_ekichange';
            return $params;
        }
        // ★★★物件一覧から→町探しページ転移
    }
    else if ($vlen >= 4)
    {
        $d = array_shift($value);
        $e = array_shift($value);

        if ($b == 'detail')
        {
            $params['Pattern'] = 'mobileapi_detail';
            $params['Type'] = 'detail2';
            $params['Code'] = $c;
            $params['Map'] = $d;
            return $params;
        }
        // 建物詳細
        if ($b == 'article')
        {
            $params['Pattern'] = 'mobileapi_article';
            $params['Type'] = 'detail2';
            $params['Code'] = $c;
            return $params;
        }
        if ($b == 'shop')
        {
            if (ereg('^[0-9]+$', $c))
            {
                $params['Pattern'] = 'mobileapi_shopdetail';
                $params['Code'] = $c;
                $params['Map'] = $d;
                return $params;
            }
        }

        // 通勤通学検索 add jschoi 20141217
        if ($b == 'search')
        {
            if ($c != 'requestsearch')
            {
                $params['Pattern'] = 'mobileapi_search';
                $params['Method'] = $c;
            }
            else
            {
                $params['Pattern'] = 'mobileapi_requestsearch';
                $params['Method'] = $d;

                if ($d == "regist") $params['Pattern'] = "mobileapi_requestsearch_regist";
            }
            return $params;
        }
        // 通勤通学検索

        if (in_array($b, Apm_Config_Search::$TODOUFUKEN_NAME_CODE_LIST))
        {
            if ($c == 'chiiki')
            {
                $params['Pattern'] = 'mobileapi_area';
                $params['Area'] = $b;
                return $params;
            }
            if ($c == 'station')
            {
                $params['Pattern'] = 'mobileapi_area';
                $params['Area'] = $b;
                $params['Category'] = 'line';
                return $params;
            }
            if ($c == 'shop')
            {
                $params['Pattern'] = 'mobileapi_shopsearch';
                $params['Area'] = $b;
                $params['Category'] = $d;
                return $params;
            }
            if (ereg("^[0-9]+$", $c))
            {
                $clen = strlen($c);
                if ($clen == 4)
                {
                    $params['Pattern'] = 'mobileapi_area';
                    $params['Area'] = $b;
                    $params['Category'] = 'line';
                    $params['RailCd'] = $c;
                    return $params;
                }
                if ($clen == 3)
                {
                    $params['Pattern'] = 'mobileapi_list';
                    $code = array_search($b, Apm_Config_Search::$TODOUFUKEN_NAME_CODE_LIST);
                    $params['Area'] = 'area';
                    $params['Code'] = $code . '-' . $code . $c;
                    $params['Page'] = $e ? $e : 1;
                    return $params;
                }
                if ($clen == 7)
                {
                    $params['Pattern'] = 'mobileapi_list';
                    $code = array_search($b, Apm_Config_Search::$TODOUFUKEN_NAME_CODE_LIST);
                    $params['Area'] = 'line';
                    $params['Code'] = $code . '-' . $c;
                    $params['Page'] = $e ? $e : 1;
                    return $params;
                }
                if ($clen == 5)
                {
                    $params['Pattern'] = 'mobileapi_shoplist';
                    $params['Category'] = 'area';
                    $params['Code'] = $c;
                    return $params;
                }
            }
        }

        // Ajax呼ぶ
        if ($b == 'areaajax')
        {
            $params['Pattern'] = 'mobileapi_areaajax';
            $params['AMethod'] = $c; // メソッド名
            return $params;
        }
        // Ajax呼ぶ

        // ★★★物件一覧から→町探しページ転移
        if ($method == 'POST' && $b == 'area' && $c == 'town')
        {
            $params['Pattern'] = 'mobileapi_town';
            return $params;
        }
        if ($method == 'POST' && $b == 'area' && $c == 'areachange')
        {
            $params['Pattern'] = 'mobileapi_areachange';
            return $params;
        }
        if ($method == 'POST' && $b == 'area' && $c == 'linechange')
        {
            $params['Pattern'] = 'mobileapi_linechange';
            return $params;
        }
        if ($method == 'POST' && $b == 'area' && $c == 'ekichange')
        {
            $params['Pattern'] = 'mobileapi_ekichange';
            return $params;
        }
        // ★★★物件一覧から→町探しページ転移

        // ★★★検討リスト - トゥン20141219
        if ($b == 'user')
        {
            if ($c == 'study')
            {
                $params['Pattern'] = 'mobileapi_study';
            }
            else if ($c == 'recent')
            {
                $params['Pattern'] = 'mobileapi_recent';
            }
            else if ($c == 'favirote')
            {
                $params['Pattern'] = 'mobileapi_favirote';
            }
            return $params;
        }
        // ★★★検討リスト
    }

    if ($b == "inquiry" && ($method == 'GET' || $method == 'POST'))
    {
        if ($c == 'bukkenentry' && $vlen >= 5)
        {
            $params['Pattern'] = 'mobileapi_bukkenentry';
            $params['BukkenCd'] = $d;
            $params['Step'] = $e;
            return $params;
        }
        elseif ($c == 'bukkenentry2' && $vlen >= 4)
        {
            $params['Pattern'] = 'mobileapi_bukkenentry2';
            $params['Step'] = $d;
            return $params;
        }
        elseif ($c == 'shopentry' && $vlen >= 5)
        {
            $params['Pattern'] = 'mobileapi_shopentry';
            $params['ShopCd'] = $d;
            $params['Step'] = $e;
            return $params;
        }
        elseif ($c == 'claimentry')
        {
            $params['Pattern'] = 'mobileapi_claimentry';
            return $params;
        }
        // 20141211 S_Add
        elseif ($c == 'archentry')
        {
            $params['Pattern'] = 'mobileapi_archentry';
            $params['TatemonoCd'] = $d;
            $params['Step'] = $e;
            return $params;
        }
        elseif ($c == 'etccnf')
        {
            $params['Pattern'] = 'mobileapi_etccnf';
            $params['Step'] = $d;
            return $params;
        }
        // 20141211 E_Add
        // 20141218 S_Add
        elseif ($c == 'conditionsentry')
        {
            $params['Pattern'] = 'mobileapi_conditionsentry';
            $params['Step'] = $d;
            return $params;
        }
        // 20141218 E_Add
    }

    // ------------------------------------------------------------------------

    // URL分割
    $value = split('/', $ar_url[0]);
    // 先頭の空配列を削除
    array_shift($value);

    // **固定URLチェック**
    /*
     * 物件詳細(detail)
     */
    if ($value[0] == 'detail' && isset($value[1]) && is_numeric($value[1]))
    {
        $params['Pattern'] = 'detail';
        $params['Category'] = '0';
        $params['ID'] = $value[1]; // 物件CD
        $params['buken_static'] = 1;
        return $params;
    }

    /*
     * 物件詳細(rstdtl)
     */
    if ($value[0] == 'rstdtl' && isset($value[1]) && $value[1] == 'bukendtl' && !empty($value[2]))
    {
        $params['Pattern'] = 'detail';
        $params['ID'] = $value[2]; // 物件CD
        $params['SrhKbn'] = $value[3]; // 検索区分
        if ($value[4] != 0)
        {
            $params['OemCd'] = $value[4]; // OEM
        }
        if ($value[5] != 0)
        {
            $params['ComId'] = $value[5]; // 法人
        }
        $params['buken_static'] = 0;
        return $params;
    }

    /*
     * 物件問い合わせ(通常)
     */
    if ($value[0] == 'inquiry' && isset($value[1]) && $value[1] == 'bukkenentry' && !empty($value[2]))
    {
        $params['Pattern'] = 'inquiry_b';
        $params['BukkenCd'] = $value[2]; // 物件CD
        $params['SrhKbn'] = $value[3]; // 検索区分
        if ($value[4] != 0)
        {
            $params['OemCd'] = $value[4]; // OEM
        }
        if ($value[5] != 0)
        {
            $params['ComId'] = $value[5]; // 法人
        }
        return $params;
    }

    /*
     * 物件問い合わせ(法人)
     */
    if ($value[0] == 'inquiry' && isset($value[1]) && $value[1] == 'asmemberentry' && !empty($value[2]))
    {
        $params['Pattern'] = 'inquiry_a';
        $params['ID'] = $value[2]; // 物件CD
        $params['SrhKbn'] = $value[3]; // 検索区分
        if ($value[4] != 0)
        {
            $params['OemCd'] = $value[4]; // OEM
        }
        if ($value[5] != 0)
        {
            $params['ComId'] = $value[5]; // 法人
        }
        return $params;
    }

    /*
     * 店舗詳細
     */
    if ($value[0] == 'shop' && isset($value[1]) && is_numeric($value[1]))
    {
        $params['Pattern'] = 'shop_detail';
        $params['Category'] = '0';
        $params['ShopCd'] = $value[1]; // 店舗CD
        if (empty($params['SrhKbn'])) $params['SrhKbn'] = Apm_Config_Shop::SEARCH_KUBUN_MAP;
        if (empty($params['SrhType'])) $params['SrhType'] = Apm_Config_Shop::SEARCH_TYPE_CITY;
        return $params;
    }

    /*
     * 災害時住宅支援
     */
    // if ($value[0] == 'sienjyutaku') {
    // $params['Pattern'] = 'kodawari';
    // $params['Category'] = '1';
    // $params['KodawariId'] = '38';
    // $params['SrhKbn'] = Apm_Config_Search::SRHKBN_KODAWARI;
    // return $params;
    // }

    /*
     * 加盟店サイト
     */
    if ($value[0] == 'membersite' && isset($value[1]) && is_numeric($value[1]))
    {
        $params['Pattern'] = 'shop_detail';
        $params['Category'] = '9';
        $params['ShopCd'] = $value[1]; // 店舗CD
        if (isset($value[2]) && is_numeric($value[2]))
        {
            $params['page'] = $value[2];
        }
        return $params;
    }

    // **旧URL転送**
    $new_url = '';
    /*
     * タイプ
     */
    if ($value[0] == 'type')
    {
        $new_url = substr($ar_url[0], 5); // /type削除
    }
    /*
     * エリア
     */
    if ($value[0] == 'chiiki')
    {
        // エリアCat1
        if (empty($value[2]) || $value[2] == 'index.html')
        {
            if ($value[1] == Apm_Config_Search::$AREA_NAME_CODE_LIST['01'])
            {
                // 北海道の場合
                $new_url = $value[1] . '/chiiki/';
            }
            else
            {
                $new_url = $value[1];
            }
        } // エリアCat2
        elseif (preg_match('/^([a-z]+)$/', $value[2]) || preg_match('/^([a-z]+)\.html$/', $value[2]))
        {
            $value2 = str_replace('.html', '', $value[2]);
            $new_url = $value2 . '/chiiki/';
        } // エリアCat2.5／エリアCat3
        elseif (preg_match('/^([a-z]+)-([0-9a-z]+)$/', $value[2]) || preg_match('/^([a-z]+)-([0-9a-z]+)-([0-9]+)-([0-9]+)-([0-9]+)$/', $value[2]))
        {
            $value2 = split('-', $value[2]);
            $new_url = '/' . $value2[0] . '/' . $value2[1] . '/';
            if (!empty($value2[2]) && !empty($value2[3]) && !empty($value2[4]))
            {
                // ページ、他
                if ($value2[2] == Apm_Config_Search::LISTTYPE_DEFAULT && $value2[3] == Apm_Config_Search::SORTCD_DEFAULT)
                {
                    if ($value2[4] != '1') $new_url .= $value2[4] . '/'; // デフォルト
                }
                else
                {
                    $new_url .= $value2[4] . '-' . $value2[2] . '-' . $value2[3] . '/';
                }
            }
        } // エリアCat3.5
        elseif (preg_match('/^([a-z]+)-([0-9]+)-more-([0-9]+)$/', $value[2]))
        {
            $value2 = split('-', $value[2]);
            $new_url = '/' . $value2[0] . '/' . $value2[1] . '-more/' . $value2[3] . '/';
        } // エリアCat4
        elseif (preg_match('/^([a-z]+)-([0-9]+)-([0-9a-zA-Z]+)$/', $value[2]) || preg_match('/^([a-z]+)-([0-9]+)-([0-9a-zA-Z]+)-([0-9]+)-([0-9]+)-([0-9]+)$/', $value[2]))
        {
            $value2 = split('-', $value[2]);
            $new_url = '/' . $value2[0] . '/' . $value2[1] . '-' . $value2[2] . '/';
            if (!empty($value2[3]) && !empty($value2[4]) && !empty($value2[5]))
            {
                // ページ、他
                if ($value2[3] == Apm_Config_Search::LISTTYPE_DEFAULT && $value2[4] == Apm_Config_Search::SORTCD_DEFAULT)
                {
                    if ($value2[5] != '1') $new_url .= $value2[5] . '/'; // デフォルト
                }
                else
                {
                    $new_url .= $value2[5] . '-' . $value2[3] . '-' . $value2[4] . '/';
                }
            }
        }
    }
    /*
     * 沿線・駅
     */
    if ($value[0] == 'station' && !empty($value[1]))
    {
        if (preg_match('/^([a-z]+)$/', $value[1]))
        {
            $new_url = substr($ar_url[0], 8); // /station削除
            if (empty($value[2]))
            {
                $new_url .= 'station/';
            }
        }
        elseif (preg_match('/^([a-z]+)-([0-9]+)$/', $value[1]) || preg_match('/^([a-z]+)-([0-9]+)-([0-9]+)-([0-9]+)-([0-9]+)$/', $value[1]))
        {
            $value2 = split('-', $value[1]);
            $new_url = '/' . $value2[0] . '/' . $value2[1] . '/';
            if (!empty($value2[2]) && !empty($value2[3]) && !empty($value2[4]))
            {
                // ページ、他
                if ($value2[2] == Apm_Config_Search::LISTTYPE_DEFAULT && $value2[3] == Apm_Config_Search::SORTCD_DEFAULT)
                {
                    if ($value2[4] != '1') $new_url .= $value2[4] . '/'; // デフォルト
                }
                else
                {
                    $new_url .= $value2[4] . '-' . $value2[2] . '-' . $value2[3] . '/';
                }
            }
        }
    }
    /*
     * x3
     */
    if ($value[0] == 'x3' && !empty($value[1]) && preg_match('/^([0-9]+)-([0-9]+)$/', $value[1]))
    {
        $value2 = split('-', $value[1]);
        $typeCd = array_search($value2[0], Apm_Config_Search::$TATEMONO_SYUBETU_ID_LIST);
        $kodawariId = $value2[1];
        $new_url = '/kodawari/' . $kodawariId . '/' . $typeCd . '/';
    }
    /*
     * x2,4,5
     */
    if (($value[0] == 'x2' || $value[0] == 'x4' || $value[0] == 'x5') && !empty($value[1]))
    {
        $value2 = split('-', $value[1]);
        // 住居形態・こだわりを抽出
        $front_url = '';
        if ($value[0] == 'x2')
        {
            // 住居形態
            $front_url = '/' . array_search($value2[0], Apm_Config_Search::$TATEMONO_SYUBETU_ID_LIST);
            array_shift($value2); // typeCd
        }
        elseif ($value[0] == 'x4')
        {
            // こだわり
            $front_url = '/kodawari/' . $value2[0];
            array_shift($value2); // kodawariId
        }
        elseif ($value[0] == 'x5')
        {
            // 住居形態xこだわり
            $front_url = '/kodawari/' . $value2[1] . '/' . array_search($value2[0], Apm_Config_Search::$TATEMONO_SYUBETU_ID_LIST);
            array_shift($value2); // typeCd
            array_shift($value2); // kodawariId
        }
        $front_url .= '/';
        // エリア抽出
        $back_url = '';
        if (empty($value2[1]))
        {
            // エリアCat1
            $back_url .= $value2[0] . '/';
        }
        else
        {
            // エリアCat2
            $back_url .= $value2[1] . '/';
        }
        if (!empty($value2[2]))
        {
            // エリアCat2.5 or 3
            $back_url .= $value2[2];
        }
        if (!empty($value2[3]))
        {
            if ($value2[3] == 'more')
            {
                // エリアCat3.5
                $back_url .= '-more/' . $value2[4];
            }
            else if (count($value2) == 6)
            {
                // エリアCat3(2ページ目以降)
                if ($value2[3] == Apm_Config_Search::LISTTYPE_DEFAULT && $value2[4] == Apm_Config_Search::SORTCD_DEFAULT)
                {
                    if ($value2[5] != '1') $back_url .= $value2[5] . '/'; // デフォルト
                }
                else
                {
                    $back_url .= '/' . $value2[5] . '-' . $value2[3] . '-' . $value2[4];
                }
            }
            else
            {
                // エリアCat4
                $back_url .= '-' . $value2[3];
                if (count($value2) == 7)
                {
                    // エリアCat4(2ページ目以降)
                    if ($value2[4] == Apm_Config_Search::LISTTYPE_DEFAULT && $value2[5] == Apm_Config_Search::SORTCD_DEFAULT)
                    {
                        if ($value2[6] != '1') $back_url .= $value2[6] . '/'; // デフォルト
                    }
                    else
                    {
                        $back_url .= '/' . $value2[6] . '-' . $value2[4] . '-' . $value2[5];
                    }
                }
            }
        }
        // URL結合
        if (!empty($back_url))
        {
            $new_url = $front_url . $back_url;
        }
    }
    /*
     * x2s,4s,5s
     */
    if (($value[0] == 'x2s' || $value[0] == 'x4s' || $value[0] == 'x5s') && !empty($value[1]))
    {
        $value2 = split('-', $value[1]);
        // 住居形態・こだわりを抽出
        $front_url = '';
        if ($value[0] == 'x2s')
        {
            // 住居形態
            $front_url = '/' . array_search($value2[0], Apm_Config_Search::$TATEMONO_SYUBETU_ID_LIST);
            array_shift($value2); // typeCd
        }
        elseif ($value[0] == 'x4s')
        {
            // こだわり
            $front_url = '/kodawari/' . $value2[0];
            array_shift($value2); // kodawariId
        }
        elseif ($value[0] == 'x5s')
        {
            // 住居形態xこだわり
            $front_url = '/kodawari/' . $value2[1] . '/' . array_search($value2[0], Apm_Config_Search::$TATEMONO_SYUBETU_ID_LIST);
            array_shift($value2); // typeCd
            array_shift($value2); // kodawariId
        }
        $front_url .= '/';
        // 駅抽出
        $back_url = '';
        if (!empty($value2[0]) && !empty($value2[1]))
        {
            $back_url .= $value2[0] . '/' . $value2[1] . '/';
            if (count($value2) == 5)
            {
                // ページ、他
                if ($value2[2] == Apm_Config_Search::LISTTYPE_DEFAULT && $value2[3] == Apm_Config_Search::SORTCD_DEFAULT)
                {
                    if ($value2[4] != '1') $back_url .= $value2[4] . '/'; // デフォルト
                }
                else
                {
                    $back_url .= $value2[4] . '-' . $value2[2] . '-' . $value2[3] . '/';
                }
            }
        }
        // URL結合
        if (!empty($back_url))
        {
            $new_url = $front_url . $back_url;
        }
    }

    // shop 既存URIとぶつかるためリダイレクト中止
    /*
     * if ($value[0] == 'shop' && $value[1] == 'redirect') { $new_url =
     * str_replace('/shop/redirect', '', $ar_url[0]); } if ($value[0] == 'shop' && $value[1] ==
     * 'selcity') { // 都道府県 $prefCd = "00"; $prefCnt = 0; foreach ($params as $key => $val) { if
     * (preg_match('/^PrefCd(.*)$/', $key)) { $prefCd = $val; $prefCnt++; } } $prefNm = ""; if
     * ($prefCnt == 1) $prefNm = Apm_Config_Search::$TODOUFUKEN_NAME_CODE_LIST[$prefCd]; if
     * (!empty($prefNm)) { $new_url = '/shop/redirect/'.$prefNm.'/shop'; if (!empty($ar_url[1]))
     * unset($ar_url[1]);	// パラメータ削除 } } if ($value[0] == 'shop' && $value[1] == 'rstshoplist' &&
     * $params['SrhKbn'] == '1' && $params['SrhType'] == '1' && $params['tokucho01'] == '1') { //
     * 特徴チェック $tokucho = true; foreach ($params as $key => $val) { $matches = array(); if
     * (preg_match('/^tokucho([0-9]+)$/', $key, $matches)) { if ($matches[1] != '01' && $val == '1')
     * { $tokucho = false; } } } if ($tokucho) { // 都道府県・市区町村 $prefCd = "00"; $cityCd = "00000";
     * $cityCnt = 0; foreach ($params as $key => $val) { if (preg_match('/^CityCd(.*)$/', $key)) {
     * $cityCd = $val; $cityCnt++; } } if ($cityCnt == 1 && strlen($cityCd) == 5) { $prefCd =
     * substr($cityCd, 0, 2); } $prefNm = Apm_Config_Search::$TODOUFUKEN_NAME_CODE_LIST[$prefCd]; if
     * (!empty($prefNm) && $cityCd != "00000") { $new_url =
     * '/shop/redirect/'.$prefNm.'/'.$cityCd.'/'; if (!empty($ar_url[1])) unset($ar_url[1]);	//
     * パラメータ削除 } } }
     */

    if (!empty($new_url))
    {
        // URL補助
        if (substr($new_url, 0, 1) != '/') $new_url = '/' . $new_url;
        if (substr($new_url, -1) != '/') $new_url = $new_url . '/';
        // パラメータ付与
        if (!empty($ar_url[1])) $new_url .= '?' . $ar_url[1];
        // 301リダイレクト
        __log_debug_ex("URL転送：" . $new_url);
        header("HTTP/1.1 301 Moved Permanently");
        header("Location: " . $new_url);
        header("x-pass-through:true");
        exit();
    }

    // **静的URLチェック**
    /*
     * こだわり
     */
    if ($value[0] == 'kodawari')
    {
        if (isset($value[1]) && is_numeric($value[1]))
        {
            // こだわりIDセット
            $params['KodawariId'] = $value[1];
            $params['Category'] = '1';
            // valueをシフト
            array_shift($value); // kodawari
            array_shift($value); // KodawariId
        }
        else
        {
            // こだわりTOP
            $params['Category'] = '0';
            // valueをシフト
            array_shift($value); // kodawari
        }
        $kodawariFlag = true;
    }

    /*
     * タイプ
     */
    if (array_key_exists($value[0], Apm_Config_Search::$TATEMONO_SYUBETU_ID_LIST))
    {
        // 建物種別CDセット
        $params['TatemonoTypeCd'] = Apm_Config_Search::$TATEMONO_SYUBETU_ID_LIST[$value[0]];
        $params['Category'] = '0';
        // valueをシフト
        array_shift($value); // TatemonoType
        $typeFlag = true;
    }

    /*
     * 都道府県
     */
    if (in_array($value[0], Apm_Config_Search::$TODOUFUKEN_NAME_CODE_LIST))
    {
        // 都道府県CDセット
        $params['PrefCd'][] = array_search($value[0], Apm_Config_Search::$TODOUFUKEN_NAME_CODE_LIST);
        $params['PrefName'] = $value[0];
        $params['first_check'] = $params['PrefCd'][0];
        $params['Category'] = '2';
        // valueをシフト
        array_shift($value); // PrefName
        $prefFlag = true;
    } /*
       * エリア
       */
    elseif (in_array($value[0], Apm_Config_Search::$AREA_NAME_CODE_LIST))
    {
        // エリアCDセット
        $params['AreaCd'] = array_search($value[0], Apm_Config_Search::$AREA_NAME_CODE_LIST);
        $params['AreaName'] = $value[0];
        $params['Category'] = '1';
        // valueをシフト
        array_shift($value); // AreaName
        $areaFlag = true;
    }

    /*
     * 沿線・駅検索
     */
    if ($value[0] == 'station')
    {
        // valueをシフト
        array_shift($value); // station
        $stationFlag = true;
    }

    /*
     * 地域
     */
    if ($value[0] == 'chiiki')
    {
        // valueをシフト
        array_shift($value); // chiki
        $chikiFlag = true;
    }

    /*
     * 店舗
     */
    if ($value[0] == 'shop')
    {
        // valueをシフト
        array_shift($value); // shop
        $shopFlag = true;
        // 通常アクションの場合
        if (!empty($value[0])) return array();
    }

    /*
     * 政令指定都市
     */
    if (in_array($value[0], Apm_Config_Search::$SITEITOSI_ROMAN_LIST))
    {
        // 政令指定都市CDセット
        $params['SiteitosiCd'][] = array_search($value[0], Apm_Config_Search::$SITEITOSI_ROMAN_LIST);
        $params['SiteitosiName'] = $value[0];
        $params['Category'] = '2.5';
        // valueをシフト
        array_shift($value); // SiteitosiName
    } /*
       * エリアCat3.5
       */
    elseif (preg_match('/^([0-9]+)-more$/', $value[0]))
    {
        $value2 = split('-', $value[0]);
        // 市区町村CDセット
        $params['CityCd'][] = $params['PrefCd'][0] . $value2[0];
        $params['OrgCityCd'] = $value2[0];
        $params['page'] = 1;
        $params['CityMore'] = 1;
        $params['Category'] = '3.5';
        // valueをシフト
        array_shift($value); // CityCd-more
    } /*
       * 沿線・駅Cat2.5l
       */
    elseif (preg_match('/^([0-9]+)-list$/', $value[0]))
    {
        $value2 = split('-', $value[0]);
        // 市区町村CDセット
        $params['RailCd'][] = $value2[0];
        $params['Category'] = '2.5l';
        $stationFlag = true;
        // valueをシフト
        array_shift($value); // RailCd-list
    } /*
       * 町域
       */
    elseif (preg_match('/^([0-9]+)-([0-9a-zA-Z]+)$/', $value[0]))
    {
        $value2 = split('-', $value[0]);
        // 市区町村・町域CDセット
        $params['CityCd'][] = $params['PrefCd'][0] . $value2[0];
        $params['OrgCityCd'] = $value2[0];
        $params['TownCd'][] = $params['PrefCd'][0] . $value2[0] . $value2[1];
        $params['OrgTownCd'] = $value2[1];
        $params['Category'] = '4';
        // valueをシフト
        array_shift($value); // CityCd-TownCd
    } /*
       * 市区町村／沿線／駅／店舗市区町村
       */
    elseif (is_numeric($value[0]))
    {
        switch (strlen($value[0]))
        {
            case 3: // 市区町村
                    // 市区町村CDセット
                $params['CityCd'][] = $params['PrefCd'][0] . $value[0];
                $params['OrgCityCd'] = $value[0];
                $params['Category'] = '3';
                break;
            case 4: // 沿線
                    // 沿線CDセット
                $params['RailCd'][] = $value[0];
                if ($prefFlag)
                    $params['Category'] = '2.5';
                else $params['Category'] = '2';
                $stationFlag = true;
                break;
            case 7: // 駅
                    // 駅CDセット
                $params['RailCd'][] = substr($value[0], 0, 4); // 駅CDを分割して沿線CDへ
                $params['StCd'][] = $value[0];
                $params['Category'] = '3';
                $stationFlag = true;
                break;
            case 5: // 店舗市区町村(都道府県CD+市区町村CD)
                    // 市区町村CDセット
                $params['CityCd'][] = $value[0];
                $params['Category'] = '3';
                $shopFlag = true;
                break;
        }
        // valueをシフト
        array_shift($value);
    }

    /*
     * ページ-タブ-ソート
     */
    if (preg_match('/^([0-9]+)$/', $value[0]) || preg_match('/^([0-9]+)-([0-9]+)-([0-9]+)$/', $value[0]))
    {
        $value2 = split('-', $value[0]);
        // パラメータセット
        if (!empty($value2[2]))
        {
            $params['RstobiDispType'] = $value2[1];
            $params['SortCd'] = $value2[2];
            if ($params['RstobiDispType'] == Apm_Config_Search::LISTTYPE_SHOP)
            {
                $params['shop_page'] = $value2[0];
            }
            else
            {
                $params['page'] = $value2[0];
            }
        }
        else
        {
            $params['page'] = $value2[0];
        }
        if (!empty($params['CityMore'])) $params['CityMore'] = $params['page'];
        // valueをシフト
        array_shift($value);
    }

    // **パターン割り出し**
    // 店舗検索
    if ($shopFlag)
    {
        $params['Pattern'] = 'shop';
        if (empty($params['Category']))
        {
            $params['Category'] = '0';
        }
        else
        {
            $params['SrhKbn'] = Apm_Config_Shop::SEARCH_KUBUN_MAP;
            $params['SrhType'] = Apm_Config_Shop::SEARCH_TYPE_CITY;
        }
    } // 沿線・駅検索
    elseif ($stationFlag)
    {
        if ($params['Category'] == '3')
        {
            // 沿線・駅Cat3
            if ($typeFlag && $kodawariFlag)
                $params['Pattern'] = 'x5s';
            elseif ($typeFlag)
                $params['Pattern'] = 'x2s';
            elseif ($kodawariFlag)
                $params['Pattern'] = 'x4s';
            else $params['Pattern'] = 'station';
        }
        else
        {
            $params['Pattern'] = 'station';
            if (empty($params['Category']))
            {
                if ($prefFlag)

                    // 沿線・駅Cat1
                    $params['Category'] = '1';
                else                 // 沿線・駅TOP
                $params['Category'] = '0';
            }
        }
        $params['SrhKbn'] = Apm_Config_Search::SRHKBN_ENSENEKI;
    }
    elseif ($areaFlag || $prefFlag || $typeFlag || $kodawariFlag)
    {
        if ($typeFlag && $kodawariFlag)
        {
            if ($areaFlag || $prefFlag)
            {
                // 住居形態xエリアxこだわり
                $params['Pattern'] = 'x5';
            }
            else
            {
                // 住居形態xこだわり
                $params['Pattern'] = 'x3';
                $params['Category'] = '1';
            }
            $params['SrhKbn'] = Apm_Config_Search::SRHKBN_JYUKYOKEITAI;
        }
        else if ($typeFlag)
        {
            // 住居形態検索
            if ($areaFlag || $prefFlag)
                $params['Pattern'] = 'x2';
            else $params['Pattern'] = 'type';
            $params['SrhKbn'] = Apm_Config_Search::SRHKBN_JYUKYOKEITAI;
        }
        else if ($kodawariFlag)
        {
            // こだわり検索
            if ($areaFlag || $prefFlag)
                $params['Pattern'] = 'x4';
            else $params['Pattern'] = 'kodawari';
            $params['SrhKbn'] = Apm_Config_Search::SRHKBN_KODAWARI;
        }
        else
        {
            // 住所検索
            $params['Pattern'] = 'chiiki';
            if ($params['Category'] == '2' && !$chikiFlag) $params['Category'] = '1.5';
            if ($params['Category'] == '1' || $params['Category'] == '1.5')
                $params['SrhKbn'] = Apm_Config_Search::SRHKBN_AREA;
            else $params['SrhKbn'] = Apm_Config_Search::SRHKBN_JYUSYO;
        }
    }

    return $params;
}

function __get_parameters_by_url_for_sp_backup($url, $method)
{
    $params = array();

    // パラメータをセット
    $ar_params = '';
    $ar_url = explode('?', $url);
    $ar_page = explode('/', $ar_url[0]);
    $ar_params = explode('&', $ar_url[1]);

    if (is_array($ar_params))
    {
        foreach ($ar_params as $key => $val)
        {
            if (!empty($val))
            {
                $ar_val = explode('=', $val);
                $params[$ar_val[0]] = $ar_val[1];
            }
        }
    }

    // ※TODOUFUKEN_NAMEを先にチェックすることに注意.
    // AREA_NAMEを先にチェックすると /hokkaido/ をtopにルーティングしてしまう.
    if ($ar_page[2] == '')
    {
        $params['Controller'] = 'top';
        __adebug('move: top page'); // OK
    }
    elseif (in_array($ar_page[2], Apm_Config_Sp::$PAGE))
    {
        $params['Controller'] = $ar_page[2];
        switch ($ar_page[2])
        {
            case 'bukken':
                if (isset($ar_page[3]))
                {
                    $params['step'] = $ar_page[3];
                }
                else
                {
                    $params['step'] = 'index';
                }
                break;
            case 'area':
                if (isset($ar_page[3]))
                {
                    $params['step'] = $ar_page[3];
                }
                else
                {
                    $params['step'] = 'index';
                }
                break;
            case 'article':
                if (isset($ar_page[3]))
                {
                    $params['step'] = $ar_page[3];
                }
                else
                {
                    $params['step'] = 'detail';
                }
                break;
            case 'shop':
                if (isset($ar_page[3]))
                {
                    $params['step'] = $ar_page[3];
                }
                else
                {
                    $params['step'] = 'index';
                }
                break;
            case 'shopselcity':
                if (isset($ar_page[3]))
                {
                    $params['step'] = $ar_page[3];
                }
                else
                {
                    $params['step'] = 'result_area';
                }
                break;
            case 'shopselrail':
                if (isset($ar_page[3]))
                {
                    $params['step'] = $ar_page[3];
                }
                else
                {
                    $params['step'] = 'result_line';
                }
                break;
            case 'inquiry':
                if (isset($ar_page[3]))
                {
                    $params['step'] = $ar_page[3];
                    if (isset($ar_page[4]))
                    {
                        $params['step2'] = $ar_page[4];
                    }
                    else
                    {
                        $params['step2'] = 'index';
                    }
                }
                else
                {
                    $params['step'] = 'bukken';
                    $params['step2'] = 'index';
                }
                break;
        }
        __adebug('move:' . $ar_page[2] . ' page');
    }
    elseif (in_array($ar_page[2], Apm_Config_Search::$TODOUFUKEN_NAME_CODE_LIST))
    {
        $params['Controller'] = 'area';
        $params['Area'] = $ar_page[2];
        if (isset($ar_page[3]))
        {
            if ($ar_page[3] == 'shop')
            {
                $params['ShopFlg'] = true;
                if (isset($ar_page[4]))
                {
                    $params['StationFlg'] = $ar_page[4] == 'line' ? true : false;
                }
                else
                {
                    $params['StationFlg'] = false;
                }
            }
            else
            {
                $params['ShopFlg'] = false;
                if (isset($ar_page[3]))
                {
                    $params['StationFlg'] = $ar_page[3] == 'station' ? true : false;
                }
                else
                {
                    $params['StationFlg'] = false;
                }
            }
        }
        __adebug($ar_page);
        __adebug('move: pref ' . $ar_page[2] . ' page');
    }
    elseif (in_array($ar_page[2], Apm_Config_Search::$AREA_NAME_CODE_LIST))
    {
        $params['Controller'] = 'top';
        $params['Area'] = $ar_page[2];
        __adebug('move: area ' . $ar_page[2] . ' page'); // OK
    }
    else
    {
        $params['Controller'] = '404';
        __adebug('move: 404 page');
    }

    return $params;
}

/**
 * 静的URL振り分け(backup)
 *
 * @access public
 * @param string $url
 *            静的URL
 * @return void
 */
function __get_parameters_by_url_backup($url)
{
    $params = array();
    $value = array();
    $value2 = array();

    /*
     * タイプ
     */
    if (preg_match("/\/type\//", $url))
    {

        // 住居形態TOP
        if (ereg('^/type/(.*)/', $url))
        {

            $value = split('/', $url);
            $value2 = split('-', $value[3]);

            $params['Pattern'] = 'type';
            $params['Category'] = '0';
            $params['TatemonoTypeCd'] = $value[2];
        }
    }

    /*
     * エリア
     */
    if (preg_match("/\/chiiki\//", $url))
    {

        // エリアCat2.5
        if (ereg('^/chiiki/([a-z]+)/([a-z]+)-([a-z]+)/', $url))
        {

            $value = split('/', $url);
            $value2 = split('-', $value[3]);

            $params['Pattern'] = 'chiiki';
            $params['Category'] = '2.5';
            $params['AreaCd'] = array_search($value[2], Apm_Config_Search::$AREA_NAME_CODE_LIST);
            $params['PrefName'] = $value2[0];
            $params['PrefCd'][] = _convertTodoufukenNameToCode($value2[0]);
            $params['first_check'] = $params['PrefCd'][0];
            $params['SiteitosiName'] = $value2[1];
            $params['SrhKbn'] = Apm_Config_Search::SRHKBN_JYUSYO;
        } // エリアCat3.5
        elseif (ereg('^/chiiki/([a-z]+)/([a-z]+)-([0-9]+)-more-([0-9]+)/', $url))
        {

            $value = split('/', $url);
            $value2 = split('-', $value[3]);

            $params['Pattern'] = 'chiiki';
            $params['Category'] = '3.5';
            $params['AreaCd'] = array_search($value[2], Apm_Config_Search::$AREA_NAME_CODE_LIST);
            $params['PrefName'] = $value2[0];
            $params['PrefCd'][] = _convertTodoufukenNameToCode($value2[0]);
            $params['first_check'] = $params['PrefCd'][0];
            $params['CityCd'][] = $params['PrefCd'][0] . $value2[1];
            $params['page'] = $value2[3];
            $params['SrhKbn'] = Apm_Config_Search::SRHKBN_JYUSYO;
            $params['CityMore'] = $value2[3];
        } // エリアCat4
        elseif (ereg('^/chiiki/([a-z]+)/([a-z]+)-([0-9]+)-([0-9a-zA-Z]+)/', $url) || ereg('^/chiiki/([a-z]+)/([a-z]+)-([0-9]+)-([0-9a-zA-Z]+)-([0-9]+)-([0-9]+)-([0-9]+)/', $url))
        {

            $value = split('/', $url);
            $value2 = split('-', $value[3]);

            $params['Pattern'] = 'chiiki';
            $params['Category'] = '4';
            $params['AreaCd'] = array_search($value[2], Apm_Config_Search::$AREA_NAME_CODE_LIST);
            $params['PrefName'] = $value2[0];
            $params['PrefCd'][] = _convertTodoufukenNameToCode($value2[0]);
            $params['first_check'] = $params['PrefCd'][0];
            $params['CityCd'][] = $params['PrefCd'][0] . $value2[1];
            $params['OrgCityCd'] = $value2[1];
            $params['TownCd'][] = $params['PrefCd'][0] . $value2[1] . $value2[2];
            $params['OrgTownCd'] = $value2[2];
            if (!empty($value2[3]))
            {
                $params['RstobiDispType'] = $value2[3];
                $params['SortCd'] = $value2[4];
                if ($params['RstobiDispType'] == Apm_Config_Search::LISTTYPE_SHOP)
                {
                    $params['shop_page'] = $value2[5];
                }
                else
                {
                    $params['page'] = $value2[5];
                }
            }
            $params['SrhKbn'] = Apm_Config_Search::SRHKBN_JYUSYO;
        } // エリアCat3
        elseif (ereg('^/chiiki/([a-z]+)/([a-z]+)-([0-9]+)/', $url) || ereg('^/chiiki/([a-z]+)/([a-z]+)-([0-9]+)-([0-9]+)-([0-9]+)-([0-9]+)/', $url))
        {

            $value = split('/', $url);
            $value2 = split('-', $value[3]);

            $params['Pattern'] = 'chiiki';
            $params['Category'] = '3';
            $params['AreaCd'] = array_search($value[2], Apm_Config_Search::$AREA_NAME_CODE_LIST);
            $params['PrefName'] = $value2[0];
            $params['PrefCd'][] = _convertTodoufukenNameToCode($value2[0]);
            $params['first_check'] = $params['PrefCd'][0];
            $params['CityCd'][] = $params['PrefCd'][0] . $value2[1];
            if (!empty($value2[3]))
            {
                $params['RstobiDispType'] = $value2[2];
                $params['SortCd'] = $value2[3];
                if ($params['RstobiDispType'] == Apm_Config_Search::LISTTYPE_SHOP)
                {
                    $params['shop_page'] = $value2[4];
                }
                else
                {
                    $params['page'] = $value2[4];
                }
            }
            $params['SrhKbn'] = Apm_Config_Search::SRHKBN_JYUSYO;
        } // エリアCat1(.htmlがついている版)
        elseif (ereg('^/chiiki/([a-z]+)/index.html', $url))
        {

            $value = split('/', $url);
            $value2 = split('-', $value[3]);

            $params['Pattern'] = 'chiiki';
            $params['Category'] = '1';
            $params['AreaCd'] = array_search($value[2], Apm_Config_Search::$AREA_NAME_CODE_LIST);
            $params['SrhKbn'] = Apm_Config_Search::SRHKBN_AREA;
        } // エリアCat2(.htmlがついている版（エリア検索にいかせる=>住所検索へ行かせる）)
        elseif (ereg('^/chiiki/([a-z]+)/([a-z]+).html', $url))
        {

            $value = split('/', $url);
            $value2 = split('-', $value[3]);

            $params['Pattern'] = 'chiiki';
            // $params['Category'] = '2_1';
            $params['Category'] = '2';
            $params['AreaCd'] = array_search($value[2], Apm_Config_Search::$AREA_NAME_CODE_LIST);
            $params['PrefName'] = str_replace(".html", "", $value2[0]);
            $params['PrefCd'][] = _convertTodoufukenNameToCode($params['PrefName']);
            $params['first_check'] = $params['PrefCd'][0];
            $params['SrhKbn'] = Apm_Config_Search::SRHKBN_JYUSYO;
            // $params['SrhKbn'] = Apm_Config_Search::SRHKBN_AREA;
        } // エリアCat2（住所検索導線にいかせる）
        elseif (ereg('^/chiiki/([a-z]+)/([a-z]+)/', $url))
        {

            $value = split('/', $url);
            $value2 = split('-', $value[3]);

            $params['Pattern'] = 'chiiki';
            // $params['Category'] = '2_1';
            $params['Category'] = '2';
            $params['AreaCd'] = array_search($value[2], Apm_Config_Search::$AREA_NAME_CODE_LIST);
            $params['PrefName'] = str_replace(".html", "", $value2[0]);
            $params['PrefCd'][] = _convertTodoufukenNameToCode($params['PrefName']);
            $params['first_check'] = $params['PrefCd'][0];
            $params['SrhKbn'] = Apm_Config_Search::SRHKBN_JYUSYO;
        } // エリアCat1
        elseif (ereg('^/chiiki/([a-z]+)/', $url))
        {

            $value = split('/', $url);
            $value2 = split('-', $value[3]);

            $params['Pattern'] = 'chiiki';
            $params['Category'] = '1';
            $params['AreaCd'] = array_search($value[2], Apm_Config_Search::$AREA_NAME_CODE_LIST);
            $params['SrhKbn'] = Apm_Config_Search::SRHKBN_AREA;
        }
    }

    /*
     * こだわり
     */
    if (preg_match("/\/kodawari\//", $url))
    {

        // こだわりCat1
        if (ereg('^/kodawari/(.*)/', $url))
        {

            $value = split('/', $url);
            $value2 = split('-', $value[3]);

            $params['Pattern'] = 'kodawari';
            $params['Category'] = '1';
            $params['KodawariId'] = $value[2];
            $params['SrhKbn'] = Apm_Config_Search::SRHKBN_KODAWARI;
        }
        else
        {

            $params['Pattern'] = 'kodawari';
            $params['Category'] = '0';
            $params['SrhKbn'] = Apm_Config_Search::SRHKBN_KODAWARI;
        }
    }

    // 2011/03/17 災害支援住宅専用URL対応
    /*
     * 災害支援住宅
     */
    if (preg_match("/\/sienjyutaku\//", $url))
    {
        $params['Pattern'] = 'kodawari';
        $params['Category'] = '1';
        $params['KodawariId'] = '38';
        $params['SrhKbn'] = Apm_Config_Search::SRHKBN_KODAWARI;
    }

    // 2011/07/19 加盟店サイト（メンバーサイト）対応
    /*
     * 加盟店サイト
     */
    if (preg_match("/\/membersite\//", $url))
    {
        $params['Pattern'] = 'shop';
        if (ereg('^/membersite/(.*)/', $url))
        {
            $value = split('/', $url);
            $params['ShopCd'] = $value[2];
            // ADD 2011/08/30 仕様変更（ApalogTwitterフリーワード時はPOSTパラメタを生かすため）
            if ($value[3]) $params['page'] = $value[3]; // ADD　2011/08/18 加盟店サイト（メンバーサイト）恒久対応
        }
    }

    /*
     * 駅・路線
     */
    if (preg_match("/\/station\//", $url))
    {

        if (ereg('^/station/([a-z]+)/([0-9]+)/', $url))
        {
            // 都道府県を複数選択した場合の対応
            $value = split('/', $url);
            $params['Pattern'] = 'station';
            $params['Category'] = '2';
            $params['PrefName'] = $value[2];
            $params['RailCd'][] = $value[3];
            $params['PrefCd'][] = _convertTodoufukenNameToCode($value[2]);
            $params['first_check'] = $params['PrefCd'][0];
            $params['SrhKbn'] = Apm_Config_Search::SRHKBN_ENSENEKI;
        } // 駅・路線Cat1
        elseif (ereg('^/station/([a-z]+)/', $url))
        {

            $value = split('/', $url);
            $value2 = split('-', $value[2]);

            $params['Pattern'] = 'station';
            $params['Category'] = '1';
            $params['PrefName'] = $value2[0];
            $params['PrefCd'][] = _convertTodoufukenNameToCode($value2[0]);
            $params['first_check'] = $params['PrefCd'][0];
            $params['SrhKbn'] = Apm_Config_Search::SRHKBN_ENSENEKI;
        } // 駅・路線Cat2
        elseif (ereg('^/station/([0-9]+)/', $url))
        {

            $value = split('/', $url);
            $value2 = split('-', $value[2]);

            $params['Pattern'] = 'station';
            $params['Category'] = '2';
            $params['RailCd'][] = $value2[0];
            $params['SrhKbn'] = Apm_Config_Search::SRHKBN_ENSENEKI;
        } // エリアCat3（駅・路線Cat3）
        elseif (ereg('^/station/([a-z]+)-([0-9]+)/', $url) || ereg('^/station/([a-z]+)-([0-9]+)-([0-9]+)-([0-9]+)-([0-9]+)/', $url))
        {

            $value = split('/', $url);
            $value2 = split('-', $value[2]);

            $params['Pattern'] = 'station';
            $params['Category'] = '3';
            $params['PrefName'] = $value2[0];
            $params['PrefCd'][] = _convertTodoufukenNameToCode($value2[0]);
            $params['first_check'] = $params['PrefCd'][0];
            $params['StCd'][] = $value2[1];
            $params['RailCd'][] = substr($value2[1], 0, 4);
            if (!empty($value2[2]))
            {
                $params['RstobiDispType'] = $value2[2];
                $params['SortCd'] = $value2[3];
                if ($params['RstobiDispType'] == Apm_Config_Search::LISTTYPE_SHOP)
                {
                    $params['shop_page'] = $value2[4];
                }
                else
                {
                    $params['page'] = $value2[4];
                }
            }
            $params['SrhKbn'] = Apm_Config_Search::SRHKBN_ENSENEKI;
        } // 駅・路線TOP
        elseif (ereg('^/station/', $url))
        {
            $params['Pattern'] = 'station';
            $params['Category'] = '0';
            $params['SrhKbn'] = Apm_Config_Search::SRHKBN_ENSENEKI;
        }
    }

    /*
     * 住居形態×エリア
     */
    if (preg_match("/\/x2\//", $url))
    {

        // 住居形態×エリアCat1
        if (ereg('^/x2/([0-9]+)-([a-z]+)/', $url))
        {

            $value = split('/', $url);
            $value2 = split('-', $value[2]);

            $params['Pattern'] = 'x2';
            $params['Category'] = '1';
            $params['TatemonoTypeCd'] = $value2[0];
            $params['AreaCd'] = array_search($value2[1], Apm_Config_Search::$AREA_NAME_CODE_LIST);
            $params['SrhKbn'] = Apm_Config_Search::SRHKBN_JYUKYOKEITAI;
        } // 住居形態×エリアCat2
        elseif (ereg('^/x2/([0-9]+)-([a-z]+)-([a-z]+)/', $url) || ereg('^/x2/([0-9]+)-([a-z]+)-([a-z]+)-p([0-9]+)/', $url))
        {

            $value = split('/', $url);
            $value2 = split('-', $value[2]);

            $params['Pattern'] = 'x2';
            $params['Category'] = '2';
            $params['TatemonoTypeCd'] = $value2[0];
            $params['AreaCd'] = array_search($value2[1], Apm_Config_Search::$AREA_NAME_CODE_LIST);
            $params['PrefName'] = $value2[2];
            $params['PrefCd'][] = _convertTodoufukenNameToCode($value2[2]);
            $params['first_check'] = $params['PrefCd'][0];
            if (!empty($value2[3]))
            {
                $params['page'] = str_replace('p', '', $value2[3]);
            }
            $params['SrhKbn'] = Apm_Config_Search::SRHKBN_JYUKYOKEITAI;
        } // 住居形態×エリアCat2.5
        elseif (ereg('^/x2/([0-9]+)-([a-z]+)-([a-z]+)-([a-z]+)/', $url))
        {

            $value = split('/', $url);
            $value2 = split('-', $value[2]);

            $params['Pattern'] = 'x2';
            $params['Category'] = '2.5';
            $params['TatemonoTypeCd'] = $value2[0];
            $params['AreaCd'] = array_search($value2[1], Apm_Config_Search::$AREA_NAME_CODE_LIST);
            $params['PrefName'] = $value2[2];
            $params['PrefCd'][] = _convertTodoufukenNameToCode($value2[2]);
            $params['first_check'] = $params['PrefCd'][0];
            $params['SiteitosiName'] = $value2[3];
            $params['SrhKbn'] = Apm_Config_Search::SRHKBN_JYUKYOKEITAI;
        } // 住居形態×エリアCat3.5
        elseif (ereg('^/x2/([0-9]+)-([a-z]+)-([a-z]+)-([0-9]+)-more-([0-9]+)/', $url))
        {

            $value = split('/', $url);
            $value2 = split('-', $value[2]);

            $params['Pattern'] = 'x2';
            $params['Category'] = '3.5';
            $params['TatemonoTypeCd'] = $value2[0];
            $params['AreaCd'] = array_search($value2[1], Apm_Config_Search::$AREA_NAME_CODE_LIST);
            $params['PrefName'] = $value2[2];
            $params['PrefCd'][] = _convertTodoufukenNameToCode($value2[2]);
            $params['first_check'] = $params['PrefCd'][0];
            $params['CityCd'][] = $params['PrefCd'][0] . $value2[3];
            $params['OrgCityCd'] = $value2[3];
            $params['page'] = $value2[5];
            $params['SrhKbn'] = Apm_Config_Search::SRHKBN_JYUKYOKEITAI;
            $params['CityMore'] = $value2[5];
        } // 住居形態×エリアCat4
        elseif (ereg('^/x2/([0-9]+)-([a-z]+)-([a-z]+)-([0-9]+)-([0-9a-zA-Z]+)/', $url) || ereg('^/x2/([0-9]+)-([a-z]+)-([a-z]+)-([0-9]+)-([0-9a-zA-Z]+)-([0-9]+)-([0-9]+)-([0-9]+)/', $url))
        {
            $value = split('/', $url);
            $value2 = split('-', $value[2]);

            $params['Pattern'] = 'x2';
            $params['Category'] = '4';
            $params['TatemonoTypeCd'] = $value2[0];
            $params['AreaCd'] = array_search($value2[1], Apm_Config_Search::$AREA_NAME_CODE_LIST);
            $params['PrefName'] = $value2[2];
            $params['PrefCd'][] = _convertTodoufukenNameToCode($value2[2]);
            $params['first_check'] = $params['PrefCd'][0];
            $params['CityCd'][] = $params['PrefCd'][0] . $value2[3];
            $params['OrgCityCd'] = $value2[3];
            $params['TownCd'][] = $params['PrefCd'][0] . $value2[3] . $value2[4];
            $params['OrgTownCd'] = $value2[4];
            if (!empty($value2[5]))
            {
                $params['RstobiDispType'] = $value2[5];
                $params['SortCd'] = $value2[6];
                if ($params['RstobiDispType'] == Apm_Config_Search::LISTTYPE_SHOP)
                {
                    $params['shop_page'] = $value2[7];
                }
                else
                {
                    $params['page'] = $value2[7];
                }
            }
            $params['SrhKbn'] = Apm_Config_Search::SRHKBN_JYUKYOKEITAI;
            $params['SrhType'] = Apm_Config_Search::SRHTYPE_JYUSYO;
        } // 住居形態×エリアCat3
        elseif (ereg('^/x2/([0-9]+)-([a-z]+)-([a-z]+)-([0-9]+)/', $url) || ereg('^/x2/([0-9]+)-([a-z]+)-([a-z]+)-([0-9]+)-([0-9]+)-([0-9]+)-([0-9]+)/', $url))
        {

            $value = split('/', $url);
            $value2 = split('-', $value[2]);

            $params['Pattern'] = 'x2';
            $params['Category'] = '3';
            $params['TatemonoTypeCd'] = $value2[0];
            $params['AreaCd'] = array_search($value2[1], Apm_Config_Search::$AREA_NAME_CODE_LIST);
            $params['PrefName'] = $value2[2];
            $params['PrefCd'][] = _convertTodoufukenNameToCode($value2[2]);
            $params['first_check'] = $params['PrefCd'][0];
            $params['CityCd'][] = $params['PrefCd'][0] . $value2[3];
            $params['OrgCityCd'] = $value2[3];
            if (!empty($value2[4]))
            {
                $params['RstobiDispType'] = $value2[4];
                $params['SortCd'] = $value2[5];
                if ($params['RstobiDispType'] == Apm_Config_Search::LISTTYPE_SHOP)
                {
                    $params['shop_page'] = $value2[6];
                }
                else
                {
                    $params['page'] = $value2[6];
                }
            }
            $params['SrhKbn'] = Apm_Config_Search::SRHKBN_JYUKYOKEITAI;
            $params['SrhType'] = Apm_Config_Search::SRHTYPE_JYUSYO;
        }
    }

    /*
     * 住居形態×エリア（駅・路線）
     */
    if (preg_match("/\/x2s\//", $url))
    {

        // 住居形態×エリアCat3（駅・路線Cat2）
        if (ereg('^/x2s/([0-9]+)-([a-z]+)-([0-9]+)/', $url) || ereg('^/x2s/([0-9]+)-([a-z]+)-([0-9]+)-([0-9]+)-([0-9]+)-([0-9]+)/', $url))
        {

            $value = split('/', $url);
            $value2 = split('-', $value[2]);

            $params['Pattern'] = 'x2s';
            $params['Category'] = '3';
            $params['TatemonoTypeCd'] = $value2[0];
            $params['PrefName'] = $value2[1];
            $params['PrefCd'][] = _convertTodoufukenNameToCode($value2[1]);
            $params['first_check'] = $params['PrefCd'][0];
            $params['StCd'][] = $value2[2];
            $params['OrgStCd'] = $value2[2];
            $params['RailCd'][] = substr($value2[2], 0, 4);
            if (!empty($value2[3]))
            {
                $params['RstobiDispType'] = $value2[3];
                $params['SortCd'] = $value2[4];
                if ($params['RstobiDispType'] == Apm_Config_Search::LISTTYPE_SHOP)
                {
                    $params['shop_page'] = $value2[5];
                }
                else
                {
                    $params['page'] = $value2[5];
                }
            }
            $params['SrhKbn'] = Apm_Config_Search::SRHKBN_ENSENEKI;
            // $params['SrhType'] = Apm_Config_Search::SRHTYPE_ENSENEKI;
        }
    }

    /*
     * 住居形態×こだわり
     */
    if (preg_match("/\/x3\//", $url))
    {

        // 住居形態×こだわりCat1
        if (ereg('^/x3/([0-9]+)-([0-9]+)/', $url))
        {

            $value = split('/', $url);
            $value2 = split('-', $value[2]);

            $params['Pattern'] = 'x3';
            $params['Category'] = '1';
            $params['TatemonoTypeCd'] = $value2[0];
            $params['KodawariId'] = $value2[1];
            $params['SrhKbn'] = Apm_Config_Search::SRHKBN_KODAWARI;
        }
    }

    /*
     * エリア×こだわり
     */
    if (preg_match("/\/x4\//", $url))
    {

        // エリアCat1×こだわりCat1
        if (ereg('^/x4/([0-9]+)-([a-z]+)/', $url))
        {

            $value = split('/', $url);
            $value2 = split('-', $value[2]);

            $params['Pattern'] = 'x4';
            $params['Category'] = '1';
            $params['KodawariId'] = $value2[0];
            $params['AreaCd'] = array_search($value2[1], Apm_Config_Search::$AREA_NAME_CODE_LIST);
            ;
            $params['SrhKbn'] = Apm_Config_Search::SRHKBN_KODAWARI;
        } // エリアCat2×こだわりCat1
        elseif (ereg('^/x4/([0-9]+)-([a-z]+)-([a-z]+)/', $url) || ereg('^/x4/([0-9]+)-([a-z]+)-([a-z]+)-p([0-9]+)/', $url))
        {

            $value = split('/', $url);
            $value2 = split('-', $value[2]);

            $params['Pattern'] = 'x4';
            $params['Category'] = '2';
            $params['KodawariId'] = $value2[0];
            $params['AreaCd'] = array_search($value2[1], Apm_Config_Search::$AREA_NAME_CODE_LIST);
            ;
            $params['PrefName'] = $value2[2];
            $params['PrefCd'][] = _convertTodoufukenNameToCode($value2[2]);
            $params['first_check'] = $params['PrefCd'][0];
            if (!empty($value2[3]))
            {
                $params['page'] = str_replace('p', '', $value2[3]);
            }
            $params['SrhKbn'] = Apm_Config_Search::SRHKBN_KODAWARI;
        } // エリアCat2.5×こだわりCat1
        elseif (ereg('^/x4/([0-9]+)-([a-z]+)-([a-z]+)-([a-z]+)/', $url))
        {

            $value = split('/', $url);
            $value2 = split('-', $value[2]);

            $params['Pattern'] = 'x4';
            $params['Category'] = '2.5';
            $params['KodawariId'] = $value2[0];
            $params['AreaCd'] = array_search($value2[1], Apm_Config_Search::$AREA_NAME_CODE_LIST);
            $params['PrefName'] = $value2[2];
            $params['PrefCd'][] = _convertTodoufukenNameToCode($value2[2]);
            $params['first_check'] = $params['PrefCd'][0];
            $params['SiteitosiName'] = $value2[3];
            $params['SrhKbn'] = Apm_Config_Search::SRHKBN_KODAWARI;
        } // エリアCat3.5×こだわりCat1
        elseif (ereg('^/x4/([0-9]+)-([a-z]+)-([a-z]+)-([0-9]+)-more-([0-9]+)/', $url))
        {

            $value = split('/', $url);
            $value2 = split('-', $value[2]);

            $params['Pattern'] = 'x4';
            $params['Category'] = '3.5';
            $params['KodawariId'] = $value2[0];
            $params['AreaCd'] = array_search($value2[1], Apm_Config_Search::$AREA_NAME_CODE_LIST);
            $params['PrefName'] = $value2[2];
            $params['PrefCd'][] = _convertTodoufukenNameToCode($value2[2]);
            $params['first_check'] = $params['PrefCd'][0];
            $params['CityCd'][] = $params['PrefCd'][0] . $value2[3];
            $params['OrgCityCd'] = $value2[3];
            $params['page'] = $value2[5];
            $params['SrhKbn'] = Apm_Config_Search::SRHKBN_KODAWARI;
            $params['CityMore'] = $value2[5];
        } // エリアCat4×こだわりCat1
        elseif (ereg('^/x4/([0-9]+)-([a-z]+)-([a-z]+)-([0-9]+)-([0-9a-zA-Z]+)/', $url) || ereg('^/x4/([0-9]+)-([a-z]+)-([a-z]+)-([0-9]+)-([0-9a-zA-Z]+)-([0-9]+)-([0-9]+)-([0-9]+)/', $url))
        {

            $value = split('/', $url);
            $value2 = split('-', $value[2]);

            $params['Pattern'] = 'x4';
            $params['Category'] = '4';
            $params['KodawariId'] = $value2[0];
            $params['AreaCd'] = array_search($value2[1], Apm_Config_Search::$AREA_NAME_CODE_LIST);
            $params['PrefName'] = $value2[2];
            $params['PrefCd'][] = _convertTodoufukenNameToCode($value2[2]);
            $params['first_check'] = $params['PrefCd'][0];
            $params['CityCd'][] = $params['PrefCd'][0] . $value2[3];
            $params['OrgCityCd'] = $value2[3];
            $params['TownCd'][] = $params['PrefCd'][0] . $value2[3] . $value2[4];
            $params['OrgTownCd'] = $value2[4];
            if (!empty($value2[5]))
            {
                $params['RstobiDispType'] = $value2[5];
                $params['SortCd'] = $value2[6];
                if ($params['RstobiDispType'] == Apm_Config_Search::LISTTYPE_SHOP)
                {
                    $params['shop_page'] = $value2[7];
                }
                else
                {
                    $params['page'] = $value2[7];
                }
            }
            $params['SrhKbn'] = Apm_Config_Search::SRHKBN_KODAWARI;
        } // エリアCat3×こだわりCat1
        elseif (ereg('^/x4/([0-9]+)-([a-z]+)-([a-z]+)-([0-9]+)/', $url) || ereg('^/x4/([0-9]+)-([a-z]+)-([a-z]+)-([0-9]+)-([0-9]+)-([0-9]+)-([0-9]+)/', $url))
        {

            $value = split('/', $url);
            $value2 = split('-', $value[2]);

            $params['Pattern'] = 'x4';
            $params['Category'] = '3';
            $params['KodawariId'] = $value2[0];
            $params['AreaCd'] = array_search($value2[1], Apm_Config_Search::$AREA_NAME_CODE_LIST);
            $params['PrefName'] = $value2[2];
            $params['PrefCd'][] = _convertTodoufukenNameToCode($value2[2]);
            $params['first_check'] = $params['PrefCd'][0];
            $params['CityCd'][] = $params['PrefCd'][0] . $value2[3];
            $params['OrgCityCd'] = $value2[3];
            if (!empty($value2[4]))
            {
                $params['DispType'] = $value2[4];
                $params['SortCd'] = $value2[5];
                if ($params['RstobiDispType'] == Apm_Config_Search::LISTTYPE_SHOP)
                {
                    $params['shop_page'] = $value2[6];
                }
                else
                {
                    $params['page'] = $value2[6];
                }
            }
            $params['SrhKbn'] = Apm_Config_Search::SRHKBN_KODAWARI;
        }
    }

    /*
     * エリア（駅・路線）×こだわり
     */
    if (preg_match("/\/x4s\//", $url))
    {

        // エリアCat3（駅・路線Cat2）×こだわりCat1
        if (ereg('^/x4s/([0-9]+)-([a-z]+)-([0-9]+)/', $url) || ereg('^/x4s/([0-9]+)-([a-z]+)-([0-9]+)-([0-9]+)-([0-9]+)-([0-9]+)/', $url))
        {

            $value = split('/', $url);
            $value2 = split('-', $value[2]);

            $params['Pattern'] = 'x4s';
            $params['Category'] = '3';
            $params['KodawariId'] = $value2[0];
            $params['PrefName'] = $value2[1];
            $params['PrefCd'][] = _convertTodoufukenNameToCode($value2[1]);
            $params['first_check'] = $params['PrefCd'][0];
            $params['StCd'][] = $value2[2];
            $params['OrgStCd'] = $value2[2];
            $params['RailCd'][] = substr($value2[2], 0, 4);
            if (!empty($value2[3]))
            {
                $params['RstobiDispType'] = $value2[3];
                $params['SortCd'] = $value2[4];
                if ($params['RstobiDispType'] == Apm_Config_Search::LISTTYPE_SHOP)
                {
                    $params['shop_page'] = $value2[5];
                }
                else
                {
                    $params['page'] = $value2[5];
                }
            }
            $params['SrhKbn'] = Apm_Config_Search::SRHKBN_ENSENEKI;
        }
    }

    /*
     * 住居形態×エリア×こだわり
     */
    if (preg_match("/\/x5\//", $url))
    {

        // 住居形態×エリアCat1×こだわりCat1
        if (ereg('^/x5/([0-9]+)-([0-9]+)-([a-z]+)/', $url))
        {

            $value = split('/', $url);
            $value2 = split('-', $value[2]);

            $params['Pattern'] = 'x5';
            $params['Category'] = '1';
            $params['TatemonoTypeCd'] = $value2[0];
            $params['KodawariId'] = $value2[1];
            $params['AreaCd'] = array_search($value2[2], Apm_Config_Search::$AREA_NAME_CODE_LIST);
            $params['SrhKbn'] = Apm_Config_Search::SRHKBN_JYUKYOKEITAI;
        } // 住居形態×エリアCat2×こだわりCat1
        elseif (ereg('^/x5/([0-9]+)-([0-9]+)-([a-z]+)-([a-z]+)/', $url) || ereg('^/x5/([0-9]+)-([0-9]+)-([a-z]+)-([a-z]+)-p([0-9]+)/', $url))
        {

            $value = split('/', $url);
            $value2 = split('-', $value[2]);

            $params['Pattern'] = 'x5';
            $params['Category'] = '2';
            $params['TatemonoTypeCd'] = $value2[0];
            $params['KodawariId'] = $value2[1];
            $params['AreaCd'] = array_search($value2[2], Apm_Config_Search::$AREA_NAME_CODE_LIST);
            $params['PrefName'] = $value2[3];
            $params['PrefCd'][] = _convertTodoufukenNameToCode($value2[3]);
            $params['first_check'] = $params['PrefCd'][0];
            if (!empty($value2[4]))
            {
                $params['page'] = str_replace('p', '', $value2[4]);
            }
            $params['SrhKbn'] = Apm_Config_Search::SRHKBN_JYUKYOKEITAI;
        } // 住居形態×エリアCat2.5×こだわりCat1
        elseif (ereg('^/x5/([0-9]+)-([0-9]+)-([a-z]+)-([a-z]+)-([a-z]+)/', $url))
        {

            $value = split('/', $url);
            $value2 = split('-', $value[2]);

            $params['Pattern'] = 'x5';
            $params['Category'] = '2.5';
            $params['TatemonoTypeCd'] = $value2[0];
            $params['KodawariId'] = $value2[1];
            $params['AreaCd'] = array_search($value2[2], Apm_Config_Search::$AREA_NAME_CODE_LIST);
            $params['PrefName'] = $value2[3];
            $params['PrefCd'][] = _convertTodoufukenNameToCode($value2[3]);
            $params['first_check'] = $params['PrefCd'][0];
            $params['SiteitosiName'] = $value2[4];
            $params['SrhKbn'] = Apm_Config_Search::SRHKBN_JYUKYOKEITAI;
        } // 住居形態×エリアCat3.5×こだわりCat1
          // /x5/123-123-tohoku-fukushima-205-more-1/
        elseif (ereg('^/x5/([0-9]+)-([0-9]+)-([a-z]+)-([a-z]+)-([0-9]+)-more-([0-9]+)/', $url))
        {

            $value = split('/', $url);
            $value2 = split('-', $value[2]);

            $params['Pattern'] = 'x5';
            $params['Category'] = '3.5';
            $params['TatemonoTypeCd'] = $value2[0];
            $params['KodawariId'] = $value2[1];
            $params['AreaCd'] = array_search($value2[2], Apm_Config_Search::$AREA_NAME_CODE_LIST);
            $params['PrefName'] = $value2[3];
            $params['PrefCd'][] = _convertTodoufukenNameToCode($value2[3]);
            $params['first_check'] = $params['PrefCd'][0];
            $params['CityCd'][] = $params['PrefCd'][0] . $value2[4];
            $params['OrgCityCd'] = $value2[4];
            $params['page'] = $value2[6];
            $params['SrhKbn'] = Apm_Config_Search::SRHKBN_JYUKYOKEITAI;
            $params['CityMore'] = $value2[6];
        } // 住居形態×エリアCat3×こだわりCat1
          // /x5/123-123-tohoku-fukushima-205/
        elseif (ereg('^/x5/([0-9]+)-([0-9]+)-([a-z]+)-([a-z]+)-([0-9]+)/', $url) || ereg('^/x5/([0-9]+)-([0-9]+)-([a-z]+)-([a-z]+)-([0-9]+)-([0-9]+)-([0-9]+)-([0-9]+)/', $url))
        {

            $value = split('/', $url);
            $value2 = split('-', $value[2]);

            $params['Pattern'] = 'x5';
            $params['Category'] = '3';
            $params['TatemonoTypeCd'] = $value2[0];
            $params['KodawariId'] = $value2[1];
            $params['AreaCd'] = array_search($value2[2], Apm_Config_Search::$AREA_NAME_CODE_LIST);
            $params['PrefName'] = $value2[3];
            $params['PrefCd'][] = _convertTodoufukenNameToCode($value2[3]);
            $params['first_check'] = $params['PrefCd'][0];
            $params['CityCd'][] = $params['PrefCd'][0] . $value2[4];
            $params['OrgCityCd'] = $value2[4];
            if (!empty($value2[5]))
            {
                $params['RstobiDispType'] = $value2[5];
                $params['SortCd'] = $value2[6];
                if ($params['RstobiDispType'] == Apm_Config_Search::LISTTYPE_SHOP)
                {
                    $params['shop_page'] = $value2[7];
                }
                else
                {
                    $params['page'] = $value2[7];
                }
            }
            $params['SrhKbn'] = Apm_Config_Search::SRHKBN_JYUKYOKEITAI;
        } // 住居形態×エリアCat4×こだわりCat1
        elseif (ereg('^/x5/([0-9]+)-([0-9]+)-([a-z]+)-([a-z]+)-([0-9]+)-([0-9a-zA-Z]+)/', $url) || ereg('^/x5/([0-9]+)-([0-9]+)-([a-z]+)-([a-z]+)-([0-9]+)-([0-9a-zA-Z]+)-([0-9]+)-([0-9]+)-([0-9]+)/', $url))
        {

            $value = split('/', $url);
            $value2 = split('-', $value[2]);

            $params['Pattern'] = 'x5';
            $params['Category'] = '4';
            $params['TatemonoTypeCd'] = $value2[0];
            $params['KodawariId'] = $value2[1];
            $params['AreaCd'] = array_search($value2[2], Apm_Config_Search::$AREA_NAME_CODE_LIST);
            $params['PrefName'] = $value2[3];
            $params['PrefCd'][] = _convertTodoufukenNameToCode($value2[3]);
            $params['first_check'] = $params['PrefCd'][0];
            $params['CityCd'][] = $params['PrefCd'][0] . $value2[4];
            $params['OrgCityCd'] = $value2[4];
            $params['TownCd'][] = $params['PrefCd'][0] . $value2[4] . $value2[5];
            $params['OrgTownCd'] = $value2[5];
            if (!empty($value2[6]))
            {
                $params['RstobiDispType'] = $value2[6];
                $params['SortCd'] = $value2[7];
                if ($params['RstobiDispType'] == Apm_Config_Search::LISTTYPE_SHOP)
                {
                    $params['shop_page'] = $value2[8];
                }
                else
                {
                    $params['page'] = $value2[8];
                }
            }
            $params['SrhKbn'] = Apm_Config_Search::SRHKBN_JYUKYOKEITAI;
        }
    }

    /*
     * 住居形態×エリア（駅・路線）×こだわり
     */
    if (preg_match("/\/x5s\//", $url))
    {

        // 住居形態×エリアCat3（駅・路線Cat2）×こだわりCat1
        if (ereg('^/x5s/([0-9]+)-([0-9]+)-([a-z]+)-([0-9]+)/', $url) || ereg('^/x5s/([0-9]+)-([0-9]+)-([a-z]+)-([0-9]+)-([0-9]+)-([0-9]+)-([0-9]+)/', $url))
        {

            $value = split('/', $url);
            $value2 = split('-', $value[2]);

            $params['Pattern'] = 'x5s';
            $params['Category'] = '3';
            $params['TatemonoTypeCd'] = $value2[0];
            $params['KodawariId'] = $value2[1];
            $params['PrefName'] = $value2[2];
            $params['PrefCd'][] = _convertTodoufukenNameToCode($value2[2]);
            $params['first_check'] = $params['PrefCd'][0];
            $params['StCd'][] = $value2[3];
            $params['OrgStCd'] = $value2[3];
            $params['RailCd'][] = substr($value2[3], 0, 4);
            if (!empty($value2[4]))
            {
                $params['RstobiDispType'] = $value2[4];
                $params['SortCd'] = $value2[5];
                if ($params['RstobiDispType'] == Apm_Config_Search::LISTTYPE_SHOP)
                {
                    $params['shop_page'] = $value2[6];
                }
                else
                {
                    $params['page'] = $value2[6];
                }
            }
            $params['SrhKbn'] = Apm_Config_Search::SRHKBN_ENSENEKI;
        }
    }

    /*
     * 物件詳細
     */
    if (preg_match("/\/detail\//", $url))
    {

        // 物件詳細
        if (ereg('^/detail/([0-9]+)/', $url))
        {

            $value = split('/', $url);
            $value2 = split('-', $value[2]);

            $params['Pattern'] = 'detail';
            $params['Category'] = '0';
            $params['ID'] = $value2[0];
        }
        elseif (ereg('^/detail/image/([0-9]+)/', $url))
        {

            $value = split('/', $url);
            $value2 = split('-', $value[3]);

            $params['Pattern'] = 'detail';
            $params['Category'] = '1';
            $params['ID'] = $value2[0];
        }
        $params['buken_static'] = 1;
    }

    /*
     * 物件詳細2 物件詳細kodawariData処理変更 元々動的URLだったものを対応 buken_staticはパンくずの生成時に使用する
     */
    if (preg_match("/\/rstdtl\/bukendtl\//", $url))
    {

        // 物件詳細
        $value = split('/', $url);
        $params['Pattern'] = 'detail';
        $params['ID'] = $value[3];
        $params['SrhKbn'] = $value[4];
        if (0 != $value[5])
        {
            $params['OemCd'] = $value[5];
        }
        if (0 != $value[6])
        {
            $params['ComId'] = $value[6];
        }
        $params['buken_static'] = 0;
    }

    /*
     * 一括物件問い合わせ 物件詳細kodawariData処理変更 元々動的URLだったものを対応
     */
    if (preg_match("/\/inquiry\/bukkenentry\//", $url))
    {

        // 一括物件問い合わせ
        $value = split('/', $url);
        $params['Pattern'] = 'inquiry_b';
        $params['BukkenCd'] = $value[3];
        $params['SrhKbn'] = $value[4];
        if (0 != $value[5])
        {
            $params['OemCd'] = $value[5];
        }
        if (0 != $value[6])
        {
            $params['ComId'] = $value[6];
        }
    }

    /*
     * 一括物件問い合わせ（社宅） 物件詳細kodawariData処理変更 元々動的URLだったものを対応
     */
    if (preg_match("/\/inquiry\/asmemberentry\//", $url))
    {

        // 一括物件問い合わせ
        $value = split('/', $url);
        $params['Pattern'] = 'inquiry_a';
        $params['ID'] = $value[3];
        $params['SrhKbn'] = $value[4];
        if (0 != $value[5])
        {
            $params['OemCd'] = $value[5];
        }
        if (0 != $value[6])
        {
            $params['ComId'] = $value[6];
        }
    }

    /*
     * 店舗詳細
     */
    if (preg_match("/\/shop\/([0-9]+)\//", $url))
    {
        $value = split('/', $url);
        $params['Pattern'] = 'shop_detail';
        $params['ShopCd'] = $value[2];
    }

    $ar_params = '';
    $ar_url = explode('?', $url);
    $ar_params = explode('&', $ar_url[1]);
    if (is_array($ar_params))
    {
        foreach ($ar_params as $key => $val)
        {
            if (!empty($val))
            {
                $ar_val = explode('=', $val);
                $params[$ar_val[0]] = $ar_val[1];
            }
        }
    }

    return $params;
}

/**
 * 住居形態URL生成
 *
 * @param string $params
 *            検索パラメータ
 * @return string $return URL
 */
function __generate_url_by_parameters_type($params, $baseurl = '/')
{
    $return = '';

    switch ($params['Category'])
    {

        case '0':
            $return = $baseurl . sprintf('%s/', $params['TatemonoType']);
            break;

        default:
            break;
    }

    return $return;
}

/**
 * エリアURL生成
 *
 * @param string $params
 *            検索パラメータ
 * @return string $return URL
 */
function __generate_url_by_parameters_chiiki($params, $baseurl = '/')
{
    $return = '';

    switch ($params['Category'])
    {

        case '1':
            if ($params['AreaName'] == 'hokkaido')
            {
                $return = $baseurl . sprintf('%s/chiiki/', $params['AreaName']);
            }
            else
            {
                $return = $baseurl . sprintf('%s/', $params['AreaName']);
            }
            break;

        case '1.5':
            $return = $baseurl . sprintf('%s/', $params['PrefName']);
            break;

        case '2':
            $return = $baseurl . sprintf('%s/chiiki/', $params['PrefName']);
            break;

        case '2.5':
            $return = $baseurl . sprintf('%s/%s/', $params['PrefName'], $params['SiteitosiName']);
            break;

        case '3':
            if ($params['page'] && $params['page'] != '1' && (empty($params['RstobiDispType']) || $params['RstobiDispType'] == Apm_Config_Search::LISTTYPE_DEFAULT) && (empty($params['SortCd']) || $params['SortCd'] == Apm_Config_Search::SORTCD_DEFAULT))
            {
                $return = $baseurl . sprintf('%s/%s/%s/', $params['PrefName'], $params['CityCd'], $params['page']);
            }
            elseif ($params['page'] && $params['RstobiDispType'] && $params['SortCd'])
            {
                $return = $baseurl . sprintf('%s/%s/%s-%s-%s/', $params['PrefName'], $params['CityCd'], $params['page'], $params['RstobiDispType'], $params['SortCd']);
            }
            else
            {
                $return = $baseurl . sprintf('%s/%s/', $params['PrefName'], $params['CityCd']);
            }
            break;

        case '3.5':
            if (empty($params['CityMore'])) $params['CityMore'] = '1';
            $return = $baseurl . sprintf('%s/%s-more/%s/', $params['PrefName'], $params['CityCd'], $params['CityMore']);
            break;

        case '4':
            if ($params['page'] && $params['page'] != '1' && (empty($params['RstobiDispType']) || $params['RstobiDispType'] == Apm_Config_Search::LISTTYPE_DEFAULT) && (empty($params['SortCd']) || $params['SortCd'] == Apm_Config_Search::SORTCD_DEFAULT))
            {
                $return = $baseurl . sprintf('%s/%s-%s/%s/', $params['PrefName'], $params['CityCd'], $params['TownCd'], $params['page']);
            }
            elseif ($params['page'] && $params['RstobiDispType'] && $params['SortCd'])
            {
                $return = $baseurl . sprintf('%s/%s-%s/%s-%s-%s/', $params['PrefName'], $params['CityCd'], $params['TownCd'], $params['page'], $params['RstobiDispType'], $params['SortCd']);
            }
            else
            {
                $return = $baseurl . sprintf('%s/%s-%s/', $params['PrefName'], $params['CityCd'], $params['TownCd']);
            }
            break;

        default:
            break;
    }

    return $return;
}

/**
 * 駅・路線URL生成
 *
 * @param string $params
 *            検索パラメータ
 * @return string $return URL
 */
function __generate_url_by_parameters_station($params, $baseurl = '/')
{
    $return = '';
    switch ($params['Category'])
    {

        case '0':
            $return = $baseurl . 'station/';
            break;

        case '1':
            $return = $baseurl . sprintf('%s/station/', $params['PrefName']);
            break;

        case '2':
            $return = $baseurl . sprintf('station/%s/', $params['RailCd']);
            break;

        case '2.5':
            $return = $baseurl . sprintf('%s/%s/', $params['PrefName'], $params['RailCd']);
            break;

        case '2.5l':
            if ($params['page'] && $params['page'] != '1' && (empty($params['RstobiDispType']) || $params['RstobiDispType'] == Apm_Config_Search::LISTTYPE_DEFAULT) && (empty($params['SortCd']) || $params['SortCd'] == Apm_Config_Search::SORTCD_DEFAULT))
            {
                $return = $baseurl . sprintf('%s/%s-list/%s/', $params['PrefName'], $params['RailCd'], $params['page']);
            }
            elseif ($params['page'] && $params['RstobiDispType'] && $params['SortCd'])
            {
                $return = $baseurl . sprintf('%s/%s-list/%s-%s-%s/', $params['PrefName'], $params['RailCd'], $params['page'], $params['RstobiDispType'], $params['SortCd']);
            }
            else
            {
                $return = $baseurl . sprintf('%s/%s-list/', $params['PrefName'], $params['RailCd']);
            }
            break;

        case '3':
            if ($params['page'] && $params['page'] != '1' && (empty($params['RstobiDispType']) || $params['RstobiDispType'] == Apm_Config_Search::LISTTYPE_DEFAULT) && (empty($params['SortCd']) || $params['SortCd'] == Apm_Config_Search::SORTCD_DEFAULT))
            {
                $return = $baseurl . sprintf('%s/%s/%s/', $params['PrefName'], $params['StCd'], $params['page']);
            }
            elseif ($params['page'] && $params['RstobiDispType'] && $params['SortCd'])
            {
                $return = $baseurl . sprintf('%s/%s/%s-%s-%s/', $params['PrefName'], $params['StCd'], $params['page'], $params['RstobiDispType'], $params['SortCd']);
            }
            else
            {
                $return = $baseurl . sprintf('%s/%s/', $params['PrefName'], $params['StCd']);
            }
            break;

        default:
            break;
    }

    return $return;
}

/**
 * こだわりURL生成
 *
 * @param string $params
 *            検索パラメータ
 * @return string $return URL
 */
function __generate_url_by_parameters_kodawari($params, $baseurl = '/')
{
    $return = '';

    switch ($params['Category'])
    {

        case '0':
            $return = $baseurl . 'kodawari/';
            break;

        case '1':
            $return = $baseurl . sprintf('kodawari/%s/', $params['KodawariId']);
            break;

        default:
            break;
    }

    return $return;
}

/**
 * 住居形態×エリアURL生成
 *
 * @param string $params
 *            検索パラメータ
 * @return string $return URL
 */
function __generate_url_by_parameters_x2($params, $baseurl = '/')
{
    $return = '';
    if (empty($params['TatemonoType']) && !empty($params['TatemonoTypeCd'])) $params['TatemonoType'] = array_search($params['TatemonoTypeCd'], Apm_Config_Search::$TATEMONO_SYUBETU_ID_LIST);

    switch ($params['Category'])
    {

        case '1':
            $return = $baseurl . sprintf('%s/%s/', $params['TatemonoType'], $params['AreaName']);
            break;

        case '2':
            $return = $baseurl . sprintf('%s/%s/', $params['TatemonoType'], $params['PrefName']);
            break;

        case '2.5':
            $return = $baseurl . sprintf('%s/%s/%s/', $params['TatemonoType'], $params['PrefName'], $params['SiteitosiName']);
            break;

        case '3':
            if ($params['page'] && $params['page'] != '1' && (empty($params['RstobiDispType']) || $params['RstobiDispType'] == Apm_Config_Search::LISTTYPE_DEFAULT) && (empty($params['SortCd']) || $params['SortCd'] == Apm_Config_Search::SORTCD_DEFAULT))
            {
                $return = $baseurl . sprintf('%s/%s/%s/%s/', $params['TatemonoType'], $params['PrefName'], $params['CityCd'], $params['page']);
            }
            elseif ($params['page'] && $params['RstobiDispType'] && $params['SortCd'])
            {
                $return = $baseurl . sprintf('%s/%s/%s/%s-%s-%s/', $params['TatemonoType'], $params['PrefName'], $params['CityCd'], $params['page'], $params['RstobiDispType'], $params['SortCd']);
            }
            else
            {
                $return = $baseurl . sprintf('%s/%s/%s/', $params['TatemonoType'], $params['PrefName'], $params['CityCd']);
            }
            break;

        case '3.5':
            if (empty($params['CityMore'])) $params['CityMore'] = '1';
            $return = $baseurl . sprintf('%s/%s/%s-more/%s/', $params['TatemonoType'], $params['PrefName'], $params['CityCd'], $params['CityMore']);
            break;

        case '4':
            if ($params['page'] && $params['page'] != '1' && (empty($params['RstobiDispType']) || $params['RstobiDispType'] == Apm_Config_Search::LISTTYPE_DEFAULT) && (empty($params['SortCd']) || $params['SortCd'] == Apm_Config_Search::SORTCD_DEFAULT))
            {
                $return = $baseurl . sprintf('%s/%s/%s-%s/%s/', $params['TatemonoType'], $params['PrefName'], $params['CityCd'], $params['TownCd'], $params['page']);
            }
            elseif ($params['page'] && $params['RstobiDispType'] && $params['SortCd'])
            {
                $return = $baseurl . sprintf('%s/%s/%s-%s/%s-%s-%s/', $params['TatemonoType'], $params['PrefName'], $params['CityCd'], $params['TownCd'], $params['page'], $params['RstobiDispType'], $params['SortCd']);
            }
            else
            {
                $return = $baseurl . sprintf('%s/%s/%s-%s/', $params['TatemonoType'], $params['PrefName'], $params['CityCd'], $params['TownCd']);
            }
            break;

        default:
            break;
    }

    return $return;
}

/**
 * 住居形態×エリア（駅・路線）URL生成
 *
 * @param string $params
 *            検索パラメータ
 * @return string $return URL
 */
function __generate_url_by_parameters_x2s($params, $baseurl = '/')
{
    $return = '';
    if (empty($params['TatemonoType']) && !empty($params['TatemonoTypeCd'])) $params['TatemonoType'] = array_search($params['TatemonoTypeCd'], Apm_Config_Search::$TATEMONO_SYUBETU_ID_LIST);

    switch ($params['Category'])
    {

        case '3':
            if ($params['page'] && $params['page'] != '1' && (empty($params['RstobiDispType']) || $params['RstobiDispType'] == Apm_Config_Search::LISTTYPE_DEFAULT) && (empty($params['SortCd']) || $params['SortCd'] == Apm_Config_Search::SORTCD_DEFAULT))
            {
                $return = $baseurl . sprintf('%s/%s/%s/%s/', $params['TatemonoType'], $params['PrefName'], $params['StCd'], $params['page']);
            }
            elseif ($params['page'] && $params['RstobiDispType'] && $params['SortCd'])
            {
                $return = $baseurl . sprintf('%s/%s/%s/%s-%s-%s/', $params['TatemonoType'], $params['PrefName'], $params['StCd'], $params['page'], $params['RstobiDispType'], $params['SortCd']);
            }
            else
            {
                $return = $baseurl . sprintf('%s/%s/%s/', $params['TatemonoType'], $params['PrefName'], $params['StCd']);
            }
            break;

        default:
            break;
    }

    return $return;
}

/**
 * 住居形態×こだわりURL生成
 *
 * @param string $params
 *            検索パラメータ
 * @return string $return URL
 */
function __generate_url_by_parameters_x3($params, $baseurl = '/')
{
    $return = '';
    if (empty($params['TatemonoType']) && !empty($params['TatemonoTypeCd'])) $params['TatemonoType'] = array_search($params['TatemonoTypeCd'], Apm_Config_Search::$TATEMONO_SYUBETU_ID_LIST);

    switch ($params['Category'])
    {

        case '1':
            $return = $baseurl . sprintf('kodawari/%s/%s/', $params['KodawariId'], $params['TatemonoType']);
            break;

        default:
            break;
    }

    return $return;
}

/**
 * エリア×こだわりURL生成
 *
 * @param string $params
 *            検索パラメータ
 * @return string $return URL
 */
function __generate_url_by_parameters_x4($params, $baseurl = '/')
{
    $return = '';

    switch ($params['Category'])
    {

        case '1':
            $return = $baseurl . sprintf('kodawari/%s/%s/', $params['KodawariId'], $params['AreaName']);
            break;

        case '2':
            $return = $baseurl . sprintf('kodawari/%s/%s/', $params['KodawariId'], $params['PrefName']);
            break;

        case '2.5':
            $return = $baseurl . sprintf('kodawari/%s/%s/%s/', $params['KodawariId'], $params['PrefName'], $params['SiteitosiName']);
            break;

        case '3':
            if ($params['page'] && $params['page'] != '1' && (empty($params['RstobiDispType']) || $params['RstobiDispType'] == Apm_Config_Search::LISTTYPE_DEFAULT) && (empty($params['SortCd']) || $params['SortCd'] == Apm_Config_Search::SORTCD_DEFAULT))
            {
                $return = $baseurl . sprintf('kodawari/%s/%s/%s/%s/', $params['KodawariId'], $params['PrefName'], $params['CityCd'], $params['page']);
            }
            elseif ($params['page'] && $params['RstobiDispType'] && $params['SortCd'])
            {
                $return = $baseurl . sprintf('kodawari/%s/%s/%s/%s-%s-%s/', $params['KodawariId'], $params['PrefName'], $params['CityCd'], $params['page'], $params['RstobiDispType'], $params['SortCd']);
            }
            else
            {
                $return = $baseurl . sprintf('kodawari/%s/%s/%s/', $params['KodawariId'], $params['PrefName'], $params['CityCd']);
            }
            break;

        case '3.5':
            if (empty($params['CityMore'])) $params['CityMore'] = '1';
            $return = $baseurl . sprintf('kodawari/%s/%s/%s-more/%s/', $params['KodawariId'], $params['PrefName'], $params['CityCd'], $params['CityMore']);
            break;

        case '4':
            if ($params['page'] && $params['page'] != '1' && (empty($params['RstobiDispType']) || $params['RstobiDispType'] == Apm_Config_Search::LISTTYPE_DEFAULT) && (empty($params['SortCd']) || $params['SortCd'] == Apm_Config_Search::SORTCD_DEFAULT))
            {
                $return = $baseurl . sprintf('kodawari/%s/%s/%s-%s/%s/', $params['KodawariId'], $params['PrefName'], $params['CityCd'], $params['TownCd'], $params['page']);
            }
            elseif ($params['page'] && $params['RstobiDispType'] && $params['SortCd'])
            {
                $return = $baseurl . sprintf('kodawari/%s/%s/%s-%s/%s-%s-%s/', $params['KodawariId'], $params['PrefName'], $params['CityCd'], $params['TownCd'], $params['page'], $params['RstobiDispType'], $params['SortCd']);
            }
            else
            {
                $return = $baseurl . sprintf('kodawari/%s/%s/%s-%s/', $params['KodawariId'], $params['PrefName'], $params['CityCd'], $params['TownCd']);
            }
            break;

        default:
            break;
    }

    return $return;
}

/**
 * エリア（駅・路線）×こだわりURL生成
 *
 * @param string $params
 *            検索パラメータ
 * @return string $return URL
 */
function __generate_url_by_parameters_x4s($params, $baseurl = '/')
{
    $return = '';

    switch ($params['Category'])
    {

        case '3':
            if ($params['page'] && $params['page'] != '1' && (empty($params['RstobiDispType']) || $params['RstobiDispType'] == Apm_Config_Search::LISTTYPE_DEFAULT) && (empty($params['SortCd']) || $params['SortCd'] == Apm_Config_Search::SORTCD_DEFAULT))
            {
                $return = $baseurl . sprintf('kodawari/%s/%s/%s/%s/', $params['KodawariId'], $params['PrefName'], $params['StCd'], $params['page']);
            }
            elseif ($params['page'] && $params['RstobiDispType'] && $params['SortCd'])
            {
                $return = $baseurl . sprintf('kodawari/%s/%s/%s/%s-%s-%s/', $params['KodawariId'], $params['PrefName'], $params['StCd'], $params['page'], $params['RstobiDispType'], $params['SortCd']);
            }
            else
            {
                $return = $baseurl . sprintf('kodawari/%s/%s/%s/', $params['KodawariId'], $params['PrefName'], $params['StCd']);
            }
            break;

        default:
            break;
    }

    return $return;
}

/**
 * 住居形態×エリア×こだわりURL生成
 *
 * @param string $params
 *            検索パラメータ
 * @return string $return URL
 */
function __generate_url_by_parameters_x5($params, $baseurl = '/')
{
    $return = '';
    if (empty($params['TatemonoType']) && !empty($params['TatemonoTypeCd'])) $params['TatemonoType'] = array_search($params['TatemonoTypeCd'], Apm_Config_Search::$TATEMONO_SYUBETU_ID_LIST);

    switch ($params['Category'])
    {

        case '1':
            $return = $baseurl . sprintf('kodawari/%s/%s/%s/', $params['KodawariId'], $params['TatemonoType'], $params['AreaName']);
            break;

        case '2':
            $return = $baseurl . sprintf('kodawari/%s/%s/%s/', $params['KodawariId'], $params['TatemonoType'], $params['PrefName']);
            break;

        case '2.5':
            $return = $baseurl . sprintf('kodawari/%s/%s/%s/%s/', $params['KodawariId'], $params['TatemonoType'], $params['PrefName'], $params['SiteitosiName']);
            break;

        case '3':
            if ($params['page'] && $params['page'] != '1' && (empty($params['RstobiDispType']) || $params['RstobiDispType'] == Apm_Config_Search::LISTTYPE_DEFAULT) && (empty($params['SortCd']) || $params['SortCd'] == Apm_Config_Search::SORTCD_DEFAULT))
            {
                $return = $baseurl . sprintf('kodawari/%s/%s/%s/%s/%s/', $params['KodawariId'], $params['TatemonoType'], $params['PrefName'], $params['CityCd'], $params['page']);
            }
            elseif ($params['page'] && $params['RstobiDispType'] && $params['SortCd'])
            {
                $return = $baseurl . sprintf('kodawari/%s/%s/%s/%s/%s-%s-%s/', $params['KodawariId'], $params['TatemonoType'], $params['PrefName'], $params['CityCd'], $params['page'], $params['RstobiDispType'], $params['SortCd']);
            }
            else
            {
                $return = $baseurl . sprintf('kodawari/%s/%s/%s/%s/', $params['KodawariId'], $params['TatemonoType'], $params['PrefName'], $params['CityCd']);
            }
            break;

        case '3.5':
            if (empty($params['CityMore'])) $params['CityMore'] = '1';
            $return = $baseurl . sprintf('kodawari/%s/%s/%s/%s-more/%s/', $params['KodawariId'], $params['TatemonoType'], $params['PrefName'], $params['CityCd'], $params['CityMore']);
            break;

        case '4':
            if ($params['page'] && $params['page'] != '1' && (empty($params['RstobiDispType']) || $params['RstobiDispType'] == Apm_Config_Search::LISTTYPE_DEFAULT) && (empty($params['SortCd']) || $params['SortCd'] == Apm_Config_Search::SORTCD_DEFAULT))
            {
                $return = $baseurl . sprintf('kodawari/%s/%s/%s/%s-%s/%s/', $params['KodawariId'], $params['TatemonoType'], $params['PrefName'], $params['CityCd'], $params['TownCd'], $params['page']);
            }
            elseif ($params['page'] && $params['RstobiDispType'] && $params['SortCd'])
            {
                $return = $baseurl . sprintf('kodawari/%s/%s/%s/%s-%s/%s-%s-%s/', $params['KodawariId'], $params['TatemonoType'], $params['PrefName'], $params['CityCd'], $params['TownCd'], $params['page'], $params['RstobiDispType'], $params['SortCd']);
            }
            else
            {
                $return = $baseurl . sprintf('kodawari/%s/%s/%s/%s-%s/', $params['KodawariId'], $params['TatemonoType'], $params['PrefName'], $params['CityCd'], $params['TownCd']);
            }
            break;

        default:
            break;
    }

    return $return;
}

/**
 * 住居形態×エリア（駅・路線）×こだわりURL生成
 *
 * @param string $params
 *            検索パラメータ
 * @return string $return URL
 */
function __generate_url_by_parameters_x5s($params, $baseurl = '/')
{
    $return = '';
    if (empty($params['TatemonoType']) && !empty($params['TatemonoTypeCd'])) $params['TatemonoType'] = array_search($params['TatemonoTypeCd'], Apm_Config_Search::$TATEMONO_SYUBETU_ID_LIST);

    switch ($params['Category'])
    {

        case '3':
            if ($params['page'] && $params['page'] != '1' && (empty($params['RstobiDispType']) || $params['RstobiDispType'] == Apm_Config_Search::LISTTYPE_DEFAULT) && (empty($params['SortCd']) || $params['SortCd'] == Apm_Config_Search::SORTCD_DEFAULT))
            {
                $return = $baseurl . sprintf('kodawari/%s/%s/%s/%s/%s/', $params['KodawariId'], $params['TatemonoType'], $params['PrefName'], $params['StCd'], $params['page']);
            }
            elseif ($params['page'] && $params['RstobiDispType'] && $params['SortCd'])
            {
                $return = $baseurl . sprintf('kodawari/%s/%s/%s/%s/%s-%s-%s/', $params['KodawariId'], $params['TatemonoType'], $params['PrefName'], $params['StCd'], $params['page'], $params['RstobiDispType'], $params['SortCd']);
            }
            else
            {
                $return = $baseurl . sprintf('kodawari/%s/%s/%s/%s/', $params['KodawariId'], $params['TatemonoType'], $params['PrefName'], $params['StCd']);
            }
            break;

        default:
            break;
    }

    return $return;
}

/**
 * 物件詳細URL生成
 *
 * @param string $params
 *            検索パラメータ
 * @return string $return URL
 */
function __generate_url_by_parameters_detail($params, $baseurl = '/')
{
    $return = '';

    switch ($params['Category'])
    {

        case '0':
            $return = $baseurl . sprintf('detail/%s/', $params['ID']);
            break;

        default:
            break;
    }

    return $return;
}

/**
 * 店舗検索URL生成
 *
 * @param string $params
 *            検索パラメータ
 * @return string $return URL
 */
function __generate_url_by_parameters_shop($params, $baseurl = '/')
{
    $return = '';

    switch ($params['Category'])
    {

        case '0':
            $return = $baseurl . 'shop/';
            break;

        case '2':
            $return = $baseurl . sprintf('%s/shop/', $params['PrefName']);
            break;

        case '3':
            if (strlen($params['CityCd']) == 3)
            {
                if (empty($params['PrefCd']) && !empty($params['PrefName'])) $params['PrefCd'] = array_search($params['PrefName'], Apm_Config_Search::$TODOUFUKEN_NAME_CODE_LIST);

                $params['CityCd'] = $params['PrefCd'] . $params['CityCd'];
            }
            if (!empty($params['PrefCd']) && empty($params['PrefName'])) $params['PrefName'] = Apm_Config_Search::$TODOUFUKEN_NAME_CODE_LIST[$params['PrefCd']];

            $return = $baseurl . sprintf('%s/%s/', $params['PrefName'], $params['CityCd']);
            break;

        default:
            break;
    }

    return $return;
}

/**
 * 店舗詳細URL生成
 *
 * @param string $params
 *            検索パラメータ
 * @return string $return URL
 */
function __generate_url_by_parameters_shop_detail($params, $baseurl = '/')
{
    $return = '';

    switch ($params['Category'])
    {

        case '0':
            $return = $baseurl . sprintf('shop/%s/', $params['ShopCd']);
            break;

        case '9': // 加盟店サイト
            $return = $baseurl . sprintf('membersite/%s/', $params['ShopCd']);
            break;

        default:
            break;
    }

    return $return;
}

/**
 * 都道府県コード変換
 *
 * @param string $param
 *            都道府県名(ローマ字)
 * @return string 都道府県コード
 */
function _convertTodoufukenNameToCode($param)
{
    return array_search($param, Apm_Config_Search::$TODOUFUKEN_NAME_CODE_LIST);
}

?>

